login  home  contents  what's new  discussion  bug reports     help  links  subscribe  changes  refresh  edit

Submitted by : Bill Page at: 2008-11-19T08:06:58-08:00 (8 years ago)
Name :
Axiom Version :
Category : Severity : Status :
Optional subject :  
Optional comment :

On 02 Jan 2007 16:44:11 +0100 Francois Maltey wrote:

A *.spad file can contain conditionals such as:

 if R is Integer then
   aFunction x == a definition for integer
 else 
   aFunction x == an other definition

Or conditionals involving has.

But the function aFunction must be an exported function. If aFunction is a local function in the package the test is always false.

So some packages export a lot of local functions, for example elemntry.spad.

axiom
)sh EF
ElementaryFunction(R: Join(Comparable,IntegralDomain),F: Join(FunctionSpace(R),RadicalCategory)) is a package constructor Abbreviation for ElementaryFunction is EF This constructor is not exposed in this frame. ------------------------------- Operations -------------------------------- acos : F -> F acosh : F -> F acot : F -> F acoth : F -> F acsc : F -> F acsch : F -> F asec : F -> F asech : F -> F asin : F -> F asinh : F -> F atan : F -> F atanh : F -> F belong? : BasicOperator -> Boolean cos : F -> F cosh : F -> F cot : F -> F coth : F -> F csc : F -> F csch : F -> F exp : F -> F iiacos : F -> F iiacosh : F -> F iiacot : F -> F iiacoth : F -> F iiacsc : F -> F iiacsch : F -> F iiasec : F -> F iiasech : F -> F iiasin : F -> F iiasinh : F -> F iiatan : F -> F iiatanh : F -> F iicos : F -> F iicosh : F -> F iicot : F -> F iicoth : F -> F iicsc : F -> F iicsch : F -> F iiexp : F -> F iilog : F -> F iisec : F -> F iisech : F -> F iisin : F -> F iisinh : F -> F iisqrt2 : () -> F iisqrt3 : () -> F iitan : F -> F iitanh : F -> F localReal? : F -> Boolean log : F -> F pi : () -> F sec : F -> F sech : F -> F sin : F -> F sinh : F -> F tan : F -> F tanh : F -> F operator : BasicOperator -> BasicOperator specialTrigs : (F,List(Record(func: F,pole: Boolean))) -> Union(F,"failed")

all the ixxx functions might be inner functions because they are defined after a conditional.

The file elmentry.spad explains
the following should be local, but are conditional

I can't find any advice about it in the 30-year book.

Where is the problem ? What can aldor do ? Export too much functions complicate the use of axiom.

You can test this very short package for expression -------------------------------------------------------------------

spad
)abbrev package TRYCOND TryConditions
TryConditions (R, F): Exports == Implementation where R : Join (OrderedSet, GcdDomain) F : Join (FunctionSpace R, TranscendentalFunctionCategory)
Exports ==> with result : F -> F expResult : F -> F
Implementation ==> add iResult : F -> F if R is Integer then iResult x == sin x expResult x == sin x else iResult x == cos x expResult x == cos x result x == iResult x
spad
   Compiling FriCAS source code from file 
      /var/zope2/var/LatexWiki/6890605327559572517-25px002.spad using 
      old system compiler.
   TRYCOND abbreviates package TryConditions 
------------------------------------------------------------------------
   initializing NRLIB TRYCOND for TryConditions 
   compiling into NRLIB TRYCOND 
****** Domain: R already in scope
****** Domain: F already in scope
   compiling local iResult : F -> F
Time: 0.50 SEC.
compiling exported expResult : F -> F Time: 0 SEC.
compiling local iResult : F -> F Time: 0.01 SEC.
compiling exported expResult : F -> F Time: 0 SEC.
compiling exported result : F -> F Time: 0 SEC.
(time taken in buildFunctor: 0)
;;; *** |TryConditions| REDEFINED
;;; *** |TryConditions| REDEFINED Time: 0 SEC.
Cumulative Statistics for Constructor TryConditions Time: 0.51 seconds
finalizing NRLIB TRYCOND Processing TryConditions for Browser database: --->-->TryConditions((result (F F))): Not documented!!!! --->-->TryConditions((expResult (F F))): Not documented!!!! --->-->TryConditions(constructor): Not documented!!!! --->-->TryConditions(): Missing Description ; compiling file "/var/zope2/var/LatexWiki/TRYCOND.NRLIB/TRYCOND.lsp" (written 16 MAR 2011 04:42:24 AM):
; /var/zope2/var/LatexWiki/TRYCOND.NRLIB/TRYCOND.fasl written ; compilation finished in 0:00:00.131 ------------------------------------------------------------------------ TryConditions is now explicitly exposed in frame initial TryConditions will be automatically loaded when needed from /var/zope2/var/LatexWiki/TRYCOND.NRLIB/TRYCOND
>> System error: The bounding indices 163 and 162 are bad for a sequence of length 162. See also: The ANSI Standard, Glossary entry for "bounding index designator" The ANSI Standard, writeup for Issue SUBSEQ-OUT-OF-BOUNDS:IS-AN-ERROR

test

axiom
-- Expect sin : result cos
result (sin x)

\label{eq1}\cos \left({\sin \left({x}\right)}\right)(1)
Type: Expression(Integer)
axiom
-- Expect cos : right  
result (sin %i)
There are 1 exposed and 1 unexposed library operations named result having 1 argument(s) but none was determined to be applicable. Use HyperDoc Browse, or issue )display op result to learn more about the available operations. Perhaps package-calling the operation or using coercions on the arguments will allow you to apply the operation.
Cannot find a definition or applicable library operation named result with argument type(s) Expression(Complex(Integer))
Perhaps you should use "@" to indicate the required return type, or "$" to specify which version of the function you need. -- Expect sin : right expResult (sin x)

\label{eq2}\sin \left({\sin \left({x}\right)}\right)(2)
Type: Expression(Integer)
axiom
-- Expect cos : right
expResult (sin %i)
There are 1 exposed and 0 unexposed library operations named expResult having 1 argument(s) but none was determined to be applicable. Use HyperDoc Browse, or issue )display op expResult to learn more about the available operations. Perhaps package-calling the operation or using coercions on the arguments will allow you to apply the operation.
Cannot find a definition or applicable library operation named expResult with argument type(s) Expression(Complex(Integer))
Perhaps you should use "@" to indicate the required return type, or "$" to specify which version of the function you need.

Apparently this error occurs whenever a non-constant condition must be evaluated.

spad
)abbrev package TRYCON2 TryCondition2
TryCondition2 (R, F): Exports == Implementation where R : Join (OrderedSet, GcdDomain) F : Join (FunctionSpace R, TranscendentalFunctionCategory)
Exports ==> with result : F -> F expResult : F -> F
Implementation ==> add iResult : F -> F funny:Boolean := true if funny then iResult x == sin x expResult x == sin x else iResult x == cos x expResult x == cos x result x == iResult x
spad
   Compiling FriCAS source code from file 
      /var/zope2/var/LatexWiki/6949795352273485972-25px004.spad using 
      old system compiler.
   TRYCON2 abbreviates package TryCondition2 
------------------------------------------------------------------------
   initializing NRLIB TRYCON2 for TryCondition2 
   compiling into NRLIB TRYCON2 
****** Domain: R already in scope
****** Domain: F already in scope
   compiling local iResult : F -> F
Time: 0.03 SEC.
compiling exported expResult : F -> F Time: 0 SEC.
compiling local iResult : F -> F Time: 0 SEC.
compiling exported expResult : F -> F Time: 0 SEC.
compiling exported result : F -> F Time: 0 SEC.
(time taken in buildFunctor: 0)
;;; *** |TryCondition2| REDEFINED
;;; *** |TryCondition2| REDEFINED Time: 0.01 SEC.
Cumulative Statistics for Constructor TryCondition2 Time: 0.04 seconds
finalizing NRLIB TRYCON2 Processing TryCondition2 for Browser database: --->-->TryCondition2((result (F F))): Not documented!!!! --->-->TryCondition2((expResult (F F))): Not documented!!!! --->-->TryCondition2(constructor): Not documented!!!! --->-->TryCondition2(): Missing Description ; compiling file "/var/zope2/var/LatexWiki/TRYCON2.NRLIB/TRYCON2.lsp" (written 16 MAR 2011 04:42:26 AM):
; /var/zope2/var/LatexWiki/TRYCON2.NRLIB/TRYCON2.fasl written ; compilation finished in 0:00:00.082 ------------------------------------------------------------------------ TryCondition2 is now explicitly exposed in frame initial TryCondition2 will be automatically loaded when needed from /var/zope2/var/LatexWiki/TRYCON2.NRLIB/TRYCON2
>> System error: The bounding indices 163 and 162 are bad for a sequence of length 162. See also: The ANSI Standard, Glossary entry for "bounding index designator" The ANSI Standard, writeup for Issue SUBSEQ-OUT-OF-BOUNDS:IS-AN-ERROR

test

axiom
-- Expect sin : failed
result (sin x)$TryCondition2(Integer,Expression Integer)

\label{eq3}\cos \left({\sin \left({x}\right)}\right)(3)
Type: Expression(Integer)
axiom
-- Expect sin : failed
result (sin %i)$TryCondition2(Complex Integer,Expression Complex Integer)
TryCondition2(Complex(Integer),Expression(Complex(Integer))) is not a valid type. -- Expect sin : right expResult (sin x)$TryCondition2(Integer,Expression Integer)

\label{eq4}\sin \left({\sin \left({x}\right)}\right)(4)
Type: Expression(Integer)
axiom
-- Expect sin : right
expResult (sin %i)$TryCondition2(Complex Integer,Expression Complex Integer)
TryCondition2(Complex(Integer),Expression(Complex(Integer))) is not a valid type.

Severity: serious => normal




  Subject:   Be Bold !!
  ( 13 subscribers )  
Please rate this page: