Internal Error : Interpreter code generation failed for expression...

View: New views
5 Messages — Rating Filter:   Alert me  

Internal Error : Interpreter code generation failed for expression...

by Michael Becker-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



    Hi,

         I have  the followin input-file


------- ma2.input -----------------------------------
fallingPower : (INT,NNI) -> INT

fallingPower (p,0) == 1
fallingPower (p,n) == p*fallingPower(p-1,n-1)

test0 () ==
   n : Matrix Integer
   n := new(3,3,0)
   for i in 1..3 repeat _
         for j in 1..3 repeat _
         n(i,j) := fallingPower(i+j,j)
   n

test1 () ==
   n : Matrix Integer
   n := new(3,3,0)
   for i in 1..3 repeat _
         for j in 1..3 repeat _
         n(i,j) := i+j
   n

test2 () ==
   n : Matrix Integer  
   n := new(3,3,0)
   for i in 1..3 repeat _
         for j in 1..3 repeat _
         n(i,j) := fallingPower(i,j)
   n


test2()
test1()
test0()
--------------------------------------------------


 reading this in axiom gives the follwing error


--------------------------------------------------

                       AXIOM Computer Algebra System
                          Version: Axiom (May 2009)
                Timestamp: Sunday June 21, 2009 at 23:34:35
-----------------------------------------------------------------------------
   Issue )copyright to view copyright notices.
   Issue )summary for a summary of useful system commands.
   Issue )quit to leave AXIOM and return to shell.
-----------------------------------------------------------------------------

   Re-reading compress.daase   Re-reading interp.daase
   Re-reading operation.daase
   Re-reading category.daase
   Re-reading browse.daase
(1) ->
(1) -> )re ma2
(1) ->


fallingPower : (INT,NNI) -> INT

                                                                   Type: Void

fallingPower (p,0) == 1

                                                                   Type: Void
fallingPower (p,n) == p*fallingPower(p-1,n-1)

                                                                   Type: Void

test0 () ==
   n : Matrix Integer
   n := new(3,3,0)
   for i in 1..3 repeat _
         for j in 1..3 repeat _
         n(i,j) := fallingPower(i+j,j)
   n

                                                                   Type: Void

test1 () ==
   n : Matrix Integer
   n := new(3,3,0)
   for i in 1..3 repeat _
         for j in 1..3 repeat _
         n(i,j) := i+j
   n

                                                                   Type: Void

test2 () ==
   n : Matrix Integer
   n := new(3,3,0)
   for i in 1..3 repeat _
         for j in 1..3 repeat _
         n(i,j) := fallingPower(i,j)
   n

                                                                   Type: Void


test2()

   Loading /usr_local/axiom0509/mnt/opensuse/algebra/MATRIX.o for
      domain Matrix
   Loading /usr_local/axiom0509/mnt/opensuse/algebra/IIARRAY2.o for
      domain InnerIndexedTwoDimensionalArray
   There are no library operations named fallingPower
      Use HyperDoc Browse or issue
                            )what op fallingPower
      to learn if there is any operation containing " fallingPower " in
      its name.
   Cannot find a definition or applicable library operation named
      fallingPower with argument type(s)
                                   Integer
                                   Integer

      Perhaps you should use "@" to indicate the required return type,
      or "$" to specify which version of the function you need.
   AXIOM will attempt to step through and interpret the code.
   Compiling function fallingPower with type (Integer,
      NonNegativeInteger) -> Integer
   Compiling function test2 with type () -> Matrix Integer
   Compiling function G1997 with type Integer -> Boolean

   Loading /usr_local/axiom0509/mnt/opensuse/algebra/MATCAT-.o for
      domain MatrixCategory&
   Loading /usr_local/axiom0509/mnt/opensuse/algebra/ARR2CAT-.o for
      domain TwoDimensionalArrayCategory&
        +1  0  0+
        |       |
   (7)  |2  2  0|
        |       |
        +3  6  6+
                                                         Type: Matrix Integer
test1()

   Compiling function test1 with type () -> Matrix Integer

        +2  3  4+
        |       |
   (8)  |3  4  5|
        |       |
        +4  5  6+
                                                         Type: Matrix Integer
test0()

   Compiling function test0 with type () -> Matrix Integer
   Loading /usr_local/axiom0509/mnt/opensuse/algebra/UPMP.o for package
      UnivariatePolynomialMultiplicationPackage
   Loading /usr_local/axiom0509/mnt/opensuse/algebra/UP.o for domain
      UnivariatePolynomial
   Internal Error
   Interpreter code generation failed for expression
      (IF (= |#2| 0) 1 (* |#1| (|fallingPower| (- |#1| 1) (- |#2| 1))))



--------------------------------------------------


 
   i can't see whats wrong with 'test0'.


    -- Michael



  ps:  same result in fricas or open-axiom.

   





------------------------------------------------------------------------------------
Diese Nachricht könnte vertrauliche und/oder rechtlich
geschützte Informationen enthalten. Wenn Sie nicht der
Adressat dieser Email sind oder nicht autorisiert sind, diese
für den Adressaten entgegenzunehmen, so ist es untersagt,
diese Nachricht oder in ihr enthaltene Informationen zu nutzen,
zu kopieren, offen zu legen oder anderweitig weiterzuverarbeiten.
Sollten Sie diese Nachricht fälschlicherweise erhalten haben,
verständigen Sie den Absender bitte unverzüglich per Antwort auf
diese Mail und löschen sie diese anschließend.
Vielen Dank für Ihre Kooperation.
------------------------------------------------------------------------------------
This message may contain confidential and/or privileged
information. If you are not the addressee or authorized
to receive this for the addressee, you must not use, copy,
disclose or take any action based on this message or any
information herein. If you have received this message in
error, please advise the sender immediately by reply e-mail
and delete this message. Thank you for your co-operation.
------------------------------------------------------------------------------------
We make your business move.




_______________________________________________
Axiom-developer mailing list
Axiom-developer@...
http://lists.nongnu.org/mailman/listinfo/axiom-developer

Re: Internal Error : Interpreter code generation failed for expression...

by Ralf Hemmecke :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Your "error" is in this line.

 > fallingPower (p,n) == p*fallingPower(p-1,n-1)

Axiom has no chance to figure out at compile time that n-1 is really of
type NNI as you required in your signature

 > fallingPower : (INT,NNI) -> INT

So the best way to deal with that is to help Axiom.

The following line works for me in FriCAS.

fallingPower (p,n) == p*fallingPower(p-1,(n-1)::NNI)

Maybe you have to add "::NNI" in a few other places.

Hope that helps
Ralf


On 07/21/2009 05:44 AM, Michael Becker wrote:

>
>     Hi,
>
>          I have  the followin input-file
>
>
> ------- ma2.input -----------------------------------
> fallingPower : (INT,NNI) -> INT
>
> fallingPower (p,0) == 1
> fallingPower (p,n) == p*fallingPower(p-1,n-1)
>
> test0 () ==
>    n : Matrix Integer
>    n := new(3,3,0)
>    for i in 1..3 repeat _
>          for j in 1..3 repeat _
>          n(i,j) := fallingPower(i+j,j)
>    n
>
> test1 () ==
>    n : Matrix Integer
>    n := new(3,3,0)
>    for i in 1..3 repeat _
>          for j in 1..3 repeat _
>          n(i,j) := i+j
>    n
>
> test2 () ==
>    n : Matrix Integer  
>    n := new(3,3,0)
>    for i in 1..3 repeat _
>          for j in 1..3 repeat _
>          n(i,j) := fallingPower(i,j)
>    n
>
>
> test2()
> test1()
> test0()
> --------------------------------------------------
>
>
>  reading this in axiom gives the follwing error
>
>
> --------------------------------------------------
>
>                        AXIOM Computer Algebra System
>                           Version: Axiom (May 2009)
>                 Timestamp: Sunday June 21, 2009 at 23:34:35
> -----------------------------------------------------------------------------
>    Issue )copyright to view copyright notices.
>    Issue )summary for a summary of useful system commands.
>    Issue )quit to leave AXIOM and return to shell.
> -----------------------------------------------------------------------------
>
>    Re-reading compress.daase   Re-reading interp.daase
>    Re-reading operation.daase
>    Re-reading category.daase
>    Re-reading browse.daase
> (1) ->
> (1) -> )re ma2
> (1) ->
>
>
> fallingPower : (INT,NNI) -> INT
>
>                                                                    Type: Void
>
> fallingPower (p,0) == 1
>
>                                                                    Type: Void
> fallingPower (p,n) == p*fallingPower(p-1,n-1)
>
>                                                                    Type: Void
>
> test0 () ==
>    n : Matrix Integer
>    n := new(3,3,0)
>    for i in 1..3 repeat _
>          for j in 1..3 repeat _
>          n(i,j) := fallingPower(i+j,j)
>    n
>
>                                                                    Type: Void
>
> test1 () ==
>    n : Matrix Integer
>    n := new(3,3,0)
>    for i in 1..3 repeat _
>          for j in 1..3 repeat _
>          n(i,j) := i+j
>    n
>
>                                                                    Type: Void
>
> test2 () ==
>    n : Matrix Integer
>    n := new(3,3,0)
>    for i in 1..3 repeat _
>          for j in 1..3 repeat _
>          n(i,j) := fallingPower(i,j)
>    n
>
>                                                                    Type: Void
>
>
> test2()
>
>    Loading /usr_local/axiom0509/mnt/opensuse/algebra/MATRIX.o for
>       domain Matrix
>    Loading /usr_local/axiom0509/mnt/opensuse/algebra/IIARRAY2.o for
>       domain InnerIndexedTwoDimensionalArray
>    There are no library operations named fallingPower
>       Use HyperDoc Browse or issue
>                             )what op fallingPower
>       to learn if there is any operation containing " fallingPower " in
>       its name.
>    Cannot find a definition or applicable library operation named
>       fallingPower with argument type(s)
>                                    Integer
>                                    Integer
>
>       Perhaps you should use "@" to indicate the required return type,
>       or "$" to specify which version of the function you need.
>    AXIOM will attempt to step through and interpret the code.
>    Compiling function fallingPower with type (Integer,
>       NonNegativeInteger) -> Integer
>    Compiling function test2 with type () -> Matrix Integer
>    Compiling function G1997 with type Integer -> Boolean
>
>    Loading /usr_local/axiom0509/mnt/opensuse/algebra/MATCAT-.o for
>       domain MatrixCategory&
>    Loading /usr_local/axiom0509/mnt/opensuse/algebra/ARR2CAT-.o for
>       domain TwoDimensionalArrayCategory&
>         +1  0  0+
>         |       |
>    (7)  |2  2  0|
>         |       |
>         +3  6  6+
>                                                          Type: Matrix Integer
> test1()
>
>    Compiling function test1 with type () -> Matrix Integer
>
>         +2  3  4+
>         |       |
>    (8)  |3  4  5|
>         |       |
>         +4  5  6+
>                                                          Type: Matrix Integer
> test0()
>
>    Compiling function test0 with type () -> Matrix Integer
>    Loading /usr_local/axiom0509/mnt/opensuse/algebra/UPMP.o for package
>       UnivariatePolynomialMultiplicationPackage
>    Loading /usr_local/axiom0509/mnt/opensuse/algebra/UP.o for domain
>       UnivariatePolynomial
>    Internal Error
>    Interpreter code generation failed for expression
>       (IF (= |#2| 0) 1 (* |#1| (|fallingPower| (- |#1| 1) (- |#2| 1))))
>
>
>
> --------------------------------------------------
>
>
>  
>    i can't see whats wrong with 'test0'.
>
>
>     -- Michael
>
>
>
>   ps:  same result in fricas or open-axiom.


_______________________________________________
Axiom-developer mailing list
Axiom-developer@...
http://lists.nongnu.org/mailman/listinfo/axiom-developer

Re: Internal Error : Interpreter code generation failed for expression...

by Michael Becker-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Am Dienstag, 21. Juli 2009 07:47 schrieb Ralf Hemmecke:

> Your "error" is in this line.
>
>  > fallingPower (p,n) == p*fallingPower(p-1,n-1)
>
> Axiom has no chance to figure out at compile time that n-1 is really of
> type NNI as you required in your signature
>
>  > fallingPower : (INT,NNI) -> INT
>
> So the best way to deal with that is to help Axiom.


     
     Ok,

        but can you explain, why  Axiom can  compile test2 ?

        the only difference is line      
                      n(i,j) := fallingPower(i+j,j)  in test0
        and
                      n(i,j) := fallingPower(i,j)  in test2


     Thanks,  

        Michael                

>
> The following line works for me in FriCAS.
>
> fallingPower (p,n) == p*fallingPower(p-1,(n-1)::NNI)
>
> Maybe you have to add "::NNI" in a few other places.
>
> Hope that helps
> Ralf
>
> On 07/21/2009 05:44 AM, Michael Becker wrote:
> >     Hi,
> >
> >          I have  the followin input-file
> >
> >
> > ------- ma2.input -----------------------------------
> > fallingPower : (INT,NNI) -> INT
> >
> > fallingPower (p,0) == 1
> > fallingPower (p,n) == p*fallingPower(p-1,n-1)
> >
> > test0 () ==
> >    n : Matrix Integer
> >    n := new(3,3,0)
> >    for i in 1..3 repeat _
> >          for j in 1..3 repeat _
> >          n(i,j) := fallingPower(i+j,j)
> >    n
> >
> > test1 () ==
> >    n : Matrix Integer
> >    n := new(3,3,0)
> >    for i in 1..3 repeat _
> >          for j in 1..3 repeat _
> >          n(i,j) := i+j
> >    n
> >
> > test2 () ==
> >    n : Matrix Integer
> >    n := new(3,3,0)
> >    for i in 1..3 repeat _
> >          for j in 1..3 repeat _
> >          n(i,j) := fallingPower(i,j)
> >    n
> >
> >
> > test2()
> > test1()
> > test0()
> > --------------------------------------------------
> >
> >
> >  reading this in axiom gives the follwing error
> >
> >
> > --------------------------------------------------
> >
> >                        AXIOM Computer Algebra System
> >                           Version: Axiom (May 2009)
> >                 Timestamp: Sunday June 21, 2009 at 23:34:35
> > -------------------------------------------------------------------------
> >---- Issue )copyright to view copyright notices.
> >    Issue )summary for a summary of useful system commands.
> >    Issue )quit to leave AXIOM and return to shell.
> > -------------------------------------------------------------------------
> >----
> >
> >    Re-reading compress.daase   Re-reading interp.daase
> >    Re-reading operation.daase
> >    Re-reading category.daase
> >    Re-reading browse.daase
> > (1) ->
> > (1) -> )re ma2
> > (1) ->
> >
> >
> > fallingPower : (INT,NNI) -> INT
> >
> >                                                                    Type:
> > Void
> >
> > fallingPower (p,0) == 1
> >
> >                                                                    Type:
> > Void fallingPower (p,n) == p*fallingPower(p-1,n-1)
> >
> >                                                                    Type:
> > Void
> >
> > test0 () ==
> >    n : Matrix Integer
> >    n := new(3,3,0)
> >    for i in 1..3 repeat _
> >          for j in 1..3 repeat _
> >          n(i,j) := fallingPower(i+j,j)
> >    n
> >
> >                                                                    Type:
> > Void
> >
> > test1 () ==
> >    n : Matrix Integer
> >    n := new(3,3,0)
> >    for i in 1..3 repeat _
> >          for j in 1..3 repeat _
> >          n(i,j) := i+j
> >    n
> >
> >                                                                    Type:
> > Void
> >
> > test2 () ==
> >    n : Matrix Integer
> >    n := new(3,3,0)
> >    for i in 1..3 repeat _
> >          for j in 1..3 repeat _
> >          n(i,j) := fallingPower(i,j)
> >    n
> >
> >                                                                    Type:
> > Void
> >
> >
> > test2()
> >
> >    Loading /usr_local/axiom0509/mnt/opensuse/algebra/MATRIX.o for
> >       domain Matrix
> >    Loading /usr_local/axiom0509/mnt/opensuse/algebra/IIARRAY2.o for
> >       domain InnerIndexedTwoDimensionalArray
> >    There are no library operations named fallingPower
> >       Use HyperDoc Browse or issue
> >                             )what op fallingPower
> >       to learn if there is any operation containing " fallingPower " in
> >       its name.
> >    Cannot find a definition or applicable library operation named
> >       fallingPower with argument type(s)
> >                                    Integer
> >                                    Integer
> >
> >       Perhaps you should use "@" to indicate the required return type,
> >       or "$" to specify which version of the function you need.
> >    AXIOM will attempt to step through and interpret the code.
> >    Compiling function fallingPower with type (Integer,
> >       NonNegativeInteger) -> Integer
> >    Compiling function test2 with type () -> Matrix Integer
> >    Compiling function G1997 with type Integer -> Boolean
> >
> >    Loading /usr_local/axiom0509/mnt/opensuse/algebra/MATCAT-.o for
> >       domain MatrixCategory&
> >    Loading /usr_local/axiom0509/mnt/opensuse/algebra/ARR2CAT-.o for
> >       domain TwoDimensionalArrayCategory&
> >         +1  0  0+
> >
> >    (7)  |2  2  0|
> >
> >         +3  6  6+
> >                                                          Type: Matrix
> > Integer test1()
> >
> >    Compiling function test1 with type () -> Matrix Integer
> >
> >         +2  3  4+
> >
> >    (8)  |3  4  5|
> >
> >         +4  5  6+
> >                                                          Type: Matrix
> > Integer test0()
> >
> >    Compiling function test0 with type () -> Matrix Integer
> >    Loading /usr_local/axiom0509/mnt/opensuse/algebra/UPMP.o for package
> >       UnivariatePolynomialMultiplicationPackage
> >    Loading /usr_local/axiom0509/mnt/opensuse/algebra/UP.o for domain
> >       UnivariatePolynomial
> >    Internal Error
> >    Interpreter code generation failed for expression
> >       (IF (= |#2| 0) 1 (* |#1| (|fallingPower| (- |#1| 1) (- |#2| 1))))
> >
> >
> >
> > --------------------------------------------------
> >
> >
> >
> >    i can't see whats wrong with 'test0'.
> >
> >
> >     -- Michael
> >
> >
> >
> >   ps:  same result in fricas or open-axiom.





------------------------------------------------------------------------------------
Diese Nachricht könnte vertrauliche und/oder rechtlich
geschützte Informationen enthalten. Wenn Sie nicht der
Adressat dieser Email sind oder nicht autorisiert sind, diese
für den Adressaten entgegenzunehmen, so ist es untersagt,
diese Nachricht oder in ihr enthaltene Informationen zu nutzen,
zu kopieren, offen zu legen oder anderweitig weiterzuverarbeiten.
Sollten Sie diese Nachricht fälschlicherweise erhalten haben,
verständigen Sie den Absender bitte unverzüglich per Antwort auf
diese Mail und löschen sie diese anschließend.
Vielen Dank für Ihre Kooperation.
------------------------------------------------------------------------------------
This message may contain confidential and/or privileged
information. If you are not the addressee or authorized
to receive this for the addressee, you must not use, copy,
disclose or take any action based on this message or any
information herein. If you have received this message in
error, please advise the sender immediately by reply e-mail
and delete this message. Thank you for your co-operation.
------------------------------------------------------------------------------------
We make your business move.




_______________________________________________
Axiom-developer mailing list
Axiom-developer@...
http://lists.nongnu.org/mailman/listinfo/axiom-developer

Re: Internal Error : Interpreter code generation failed for expression...

by Ralf Hemmecke :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

>      Ok,
>
>         but can you explain, why  Axiom can  compile test2 ?
>
>         the only difference is line      
>                       n(i,j) := fallingPower(i+j,j)  in test0
>         and
>                       n(i,j) := fallingPower(i,j)  in test2

Well my guess is that because

fallingPower (p,0) == 1
fallingPower (p,n) == p*fallingPower(p-1,(n-1)::NNI)

is a recursive definition.

Otherwise, I have no idea.

Ralf


_______________________________________________
Axiom-developer mailing list
Axiom-developer@...
http://lists.nongnu.org/mailman/listinfo/axiom-developer

Re: Internal Error : Interpreter code generation failed for expression...

by Bill Page-7 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Tue, Jul 21, 2009 at 10:46 AM, Ralf Hemmecke wrote:

>>     Ok,  but can you explain, why Axiom can compile test2 ?
>>
>>        the only difference is line
>>                      n(i,j) := fallingPower(i+j,j)  in test0
>>        and
>>                      n(i,j) := fallingPower(i,j)  in test2
>
> Well my guess is that because
>
> fallingPower (p,0) == 1
> fallingPower (p,n) == p*fallingPower(p-1,(n-1)::NNI)
>
> is a recursive definition.
>
> Otherwise, I have no idea.
>

There is nothing wrong with using a recursive definition for
'fallingPower'. Obviously Axiom should not fail with an "Internal
Error" in any case. That is clearly a bug.

I have no simple explanation about why test2 compiles successfully,
but notice that the domain NNI does not contain '-' as an operation,
so by writing

  fallingPower : (INT,NNI) -> INT
  fallingPower (p,n) == p*fallingPower(p-1,n-1)

you are actually forcing the interpreter to add some hidden automatic
conversions (coercions). It must coerce 'n' to 'Integer', do the
subtraction and then convert (retract) the result back to
NonNegativeInteger. This second conversion might not be possible.
Apparently in anything but the trivial case in-lining of this function
fails and that is a bug.

You might notice that something complicated is going on even in the
case of 'test2' because of the warning:

   Compiling function G1997 with type Integer -> Boolean

But if you simply omit the declaration, e.g. comment it out

  -- fallingPower : (INT,NNI) -> INT

then you see that Axiom actually assumes (Integer,Integer) -> Integer,
 no coercions are necessary and the code generation succeeds.

Regards,
Bill Page.


_______________________________________________
Axiom-developer mailing list
Axiom-developer@...
http://lists.nongnu.org/mailman/listinfo/axiom-developer