Discussion:
[fricas-devel] Error detected within library code:, index out of range
Kurt Pagani
2018-07-16 22:14:25 UTC
Permalink
I'm struggling with an obstinate problem:

)show SI

SIunits is a package constructor
Abbreviation for SIunits is SI
This constructor is exposed in this frame.
------------------------------- Operations --------------------------------
index out of range


Although the package compiles and works perfectly, the )show command
persistently displays "index out of range". By exclusion I could reduce the
problem to:

)abbrev package SI SIunits
SIunits : Exports == Implementation where

USY ==> ['m,'kg,'s,'A,'K,'mol,'cd]
SIU ==> PhysicalUnitSystem(USY)

Exports == with

%m : Integer -> SIU

The "-> SIU" is the source of the evil. When changing SIU to INT for example,
then there is no problem at all. I've been supposing that it might be an issue
in the interpreter code. A 'grep', however, only yields two candidates:


$ grep "index out of range" *.*
br-search.boot: if startpos < 0 or startpos > n then error "index out of range"

match.boot: if startpos < 0 or startpos > n then error "index out of range"

BTW: the full code is @ http://axiom-wiki.newsynthesis.org/SandBoxPhysicalUnitSystem

I've no idea :(
Any hints appreciated.
Kurt
--
You received this message because you are subscribed to the Google Groups "FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fricas-devel+***@googlegroups.com.
To post to this group, send email to fricas-***@googlegroups.com.
Visit this group at https://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.
Riccardo GUIDA
2018-07-17 14:47:58 UTC
Permalink
Hi Kurt

As FriCAS exercise of the day, I tried to understand the source of your bug but the best I can do is a minimal example (vaguely related to the original one) and similar errors.

I do not know what mean "non extending category" and "has no ..." compilation messages but there were similar ones in the original version.

Hope not increasing the confusion ....

ric

Cumulative Statistics for Constructor SIunits
Time: 0.00 seconds

--------------non extending category----------------------
.. SIunits of cat
(CATEGORY |package|
(SIGNATURE |u|
((|List|
(|PhysicalUnitSystem|
(|::| (|construct| '|a| '|b| '|c|) (|List| (|Symbol|)))))))) has no
(|PhysicalUnit|) finalizing NRLIB SI
Processing SIunits for Browser database:
--->-->SIunits(constructor): Not documented!!!!
--->-->SIunits((u ((List (PhysicalUnitSystem (:: (construct (QUOTE a) (QUOTE b) (QUOTE c)) (List (Symbol)))))))): Not documented!!!!
--->-->SIunits(): Missing Description
; compiling file "/data/devel/guida/WIP/fricas_learning/SI.NRLIB/SI.lsp" (written 17 JUL 2018 04:37:23 PM):

; /data/devel/guida/WIP/fricas_learning/SI.NRLIB/SI.fasl written
; compilation finished in 0:00:00.005
------------------------------------------------------------------------
SIunits is now explicitly exposed in frame frame1
SIunits will be automatically loaded when needed from
/data/devel/guida/WIP/fricas_learning/SI.NRLIB/SI

(1) -> )system cat PhysicalUnitsSystem.spad
)abbrev category PUNIT PhysicalUnit
PhysicalUnit() : Category == with
coerce : % -> OutputForm

)abbrev domain PUSYS PhysicalUnitSystem
PhysicalUnitSystem(u:List Symbol) : Exports == Implementation where
Exports == PhysicalUnit with
baseUnits : () -> List %
Implementation == add
Rep:=FreeModule(Integer,OrderedVariableList(u))
baseUnits() == [ 0$Rep]
coerce(x)== coerce(x)$Rep

)abbrev package SI SIunits
SIunits : Exports == Implementation where

Exports == with

u : () -> List(PhysicalUnitSystem(['a,'b,'c]::List(Symbol)))

Implementation == PhysicalUnitSystem(['a,'b,'c]::List(Symbol)) add

u() == baseUnits()$(PhysicalUnitSystem(['a,'b,'c]::List(Symbol)))
(1) -> )show PUSYS
PhysicalUnitSystem(u: List(Symbol)) is a domain constructor
Abbreviation for PhysicalUnitSystem is PUSYS
This constructor is exposed in this frame.
─────────────────────────────── Operations ────────────────────────────────

baseUnits : () -> List(%) coerce : % -> OutputForm

(1) -> )show SI
SIunits is a package constructor
Abbreviation for SIunits is SI
This constructor is exposed in this frame.
─────────────────────────────── Operations ────────────────────────────────
Improper script count in symbol

(1) -> u()$SI

LISP output:
()
index out of range

(1) -> )show PUSYS
PhysicalUnitSystem(u: List(Symbol)) is a domain constructor
Abbreviation for PhysicalUnitSystem is PUSYS
This constructor is exposed in this frame.
─────────────────────────────── Operations ────────────────────────────────

baseUnits : () -> List(%) coerce : % -> OutputForm

(1) ->
--
You received this message because you are subscribed to the Google Groups "FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fricas-devel+***@googlegroups.com.
To post to this group, send email to fricas-***@googlegroups.com.
Visit this group at https://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.
Kurt Pagani
2018-07-17 16:21:12 UTC
Permalink
Hello Ric

Thanks for concerning yourself with this, it might be helpful indeed.

When slightly extending it's even worse ... strange ;)
I'd expect that u()$SI worked?

---

a) PhysicalUnit() : Category == SetCategory with -- inherit from SETCAT
b) baseUnits() == [x::% for x in enumerate$OrderedVariableList(u)]

(2) -> b:=baseUnits()$PUSYS(['a,'b,'c])

(2) [a,b,c]
Type: List(PhysicalUnitSystem([a,b,c]))

(3) -> )sh SI
SIunits is a package constructor
Abbreviation for SIunits is SI
This constructor is exposed in this frame.
------------------------------- Operations --------------------------------
Improper script count in symbol

(3) -> u()$SI
index out of range
Post by Riccardo GUIDA
Hi Kurt
As FriCAS exercise of the day, I tried to understand the source of your bug but
the best I can do is a minimal example (vaguely related to the original one) and
similar errors.
I do not know what mean "non extending category" and "has no ..." compilation
messages but there were similar ones in the original version.
I guess this is of no importance w.r.t. to the error (but I may be mistaken)
Post by Riccardo GUIDA
Hope not increasing the confusion ....
Not at all.
Kurt
Post by Riccardo GUIDA
ric
--
You received this message because you are subscribed to the Google Groups "FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fricas-devel+***@googlegroups.com.
To post to this group, send email to fricas-***@googlegroups.com.
Visit this group at https://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.
Waldek Hebisch
2018-07-17 23:31:06 UTC
Permalink
Post by Kurt Pagani
Hello Ric
Thanks for concerning yourself with this, it might be helpful indeed.
When slightly extending it's even worse ... strange ;)
I'd expect that u()$SI worked?
---
a) PhysicalUnit() : Category == SetCategory with -- inherit from SETCAT
b) baseUnits() == [x::% for x in enumerate$OrderedVariableList(u)]
(2) -> b:=baseUnits()$PUSYS(['a,'b,'c])
(2) [a,b,c]
Type: List(PhysicalUnitSystem([a,b,c]))
(3) -> )sh SI
SIunits is a package constructor
Abbreviation for SIunits is SI
This constructor is exposed in this frame.
------------------------------- Operations --------------------------------
Improper script count in symbol
(3) -> u()$SI
index out of range
The error happens during printing of type. The following works:

(1) -> u()$SI; 1

(1) 1
Type: PositiveInteger

Normal way to debug such problems is to use Lisp debugger, see
doc/debug.txt in the trunk.
--
Waldek Hebisch
--
You received this message because you are subscribed to the Google Groups "FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fricas-devel+***@googlegroups.com.
To post to this group, send email to fricas-***@googlegroups.com.
Visit this group at https://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.
Kurt Pagani
2018-07-18 21:14:49 UTC
Permalink
Post by Waldek Hebisch
Normal way to debug such problems is to use Lisp debugger, see
doc/debug.txt in the trunk.
This seens different ...

)abbrev domain TEST Test
Test(s:List Symbol):A==B where
OVL ==> OrderedVariableList s
A == SetCategory with
gen:()->List %
B == FreeGroup(OVL) add
Rep:=FreeModule(Integer,OVL)
gen() == [x::% for x in enumerate$OVL]

)abbrev package PTEST Ptest
Ptest:A==B where
SL ==> ['a,'b,'c]
A == with --Test(SL) with
foo : Integer -> Test(SL)
B == add
foo(n) == (gen()$Test(SL)).n


Ptest is now explicitly exposed in frame frame0
Ptest will be automatically loaded when needed from
/cygdrive/c/users/kfp/Desktop/work/spad/PTEST.NRLIB/PTEST

(1) -> T:=Test(['a,'b,'c])

(1) Test([a,b,c])
Type: Type
(2) -> gen()$T

(2) [a, b, c]
Type: List(Test([a,b,c]))
(3) -> foo(2)$Ptest

(3) b
Type: Test([a,b,c])
(4) -> )sh Ptest
Ptest is a package constructor
Abbreviation for Ptest is PTEST
This constructor is exposed in this frame.
------------------------------- Operations --------------------------------
index out of range

(4) ->


If using A == Test(SL) with (in package PTEST):

(1) -> )version

Value = "FriCAS 1.3.3 compiled at Do, 3. Mai 2018 19:01:26"
------------------------------------------------------------------------
Test is already explicitly exposed in frame frame0
Test will be automatically loaded when needed from
/cygdrive/c/users/kfp/Desktop/work/spad/TEST.NRLIB/TEST

PTEST abbreviates package Ptest
------------------------------------------------------------------------
initializing NRLIB PTEST for Ptest
compiling into NRLIB PTEST
cannot produce category object:
(|Join| (|Test| (|construct| '|a| '|b| '|c|))
(CATEGORY |package|
(SIGNATURE |foo| ((|Test| (|construct| '|a| '|b| '|c|)) (|Integer|)))))
cannot produce category object

same on 1.3.4, while on older versions:

Value = "FriCAS 1.2.7 compiled at Sat Mar 26 17:23:40 GMT 2016"
(2) ->
------------------------------------------------------------------------
Test is now explicitly exposed in frame initial
Test will be automatically loaded when needed from
/Users/kfp/Desktop/work/spad/TEST.NRLIB/TEST

PTEST abbreviates package Ptest
------------------------------------------------------------------------
initializing NRLIB PTEST for Ptest
compiling into NRLIB PTEST
The index 2 is too large.
Post by Waldek Hebisch
Post by Kurt Pagani
Hello Ric
Thanks for concerning yourself with this, it might be helpful indeed.
When slightly extending it's even worse ... strange ;)
I'd expect that u()$SI worked?
---
a) PhysicalUnit() : Category == SetCategory with -- inherit from SETCAT
b) baseUnits() == [x::% for x in enumerate$OrderedVariableList(u)]
(2) -> b:=baseUnits()$PUSYS(['a,'b,'c])
(2) [a,b,c]
Type: List(PhysicalUnitSystem([a,b,c]))
(3) -> )sh SI
SIunits is a package constructor
Abbreviation for SIunits is SI
This constructor is exposed in this frame.
------------------------------- Operations --------------------------------
Improper script count in symbol
(3) -> u()$SI
index out of range
(1) -> u()$SI; 1
(1) 1
Type: PositiveInteger
Normal way to debug such problems is to use Lisp debugger, see
doc/debug.txt in the trunk.
--
You received this message because you are subscribed to the Google Groups "FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fricas-devel+***@googlegroups.com.
To post to this group, send email to fricas-***@googlegroups.com.
Visit this group at https://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.
Kurt Pagani
2018-07-21 19:10:17 UTC
Permalink
Hi Waldek
Post by Waldek Hebisch
Normal way to debug such problems is to use Lisp debugger, see
doc/debug.txt in the trunk.
I could trace the error to "coerceByFunction" in i-coerce.boot:

)lisp (|coerceByFunction| '((|List| (|Symbol|)) WRAPPED |construct| (QUOTE |a|)
(QUOTE |b|) (QUOTE |c|)) '(|OutputForm|))
index out of range

Furthermore, objVal and objMode seem to be ok, but it's a marvel to me what
happens next in the code. Maybe you will see it at once? (backtrace attached).
EOLatin for me :(

)lisp (|objVal| '((|List| (|Symbol|)) WRAPPED |construct| (QUOTE |a|) (QUOTE
|b|) (QUOTE |c|)))
Value = (WRAPPED |construct| '|a| '|b| '|c|)

)lisp (|objMode| '((|List| (|Symbol|)) WRAPPED |construct| (QUOTE |a|) (QUOTE
|b|) (QUOTE |c|)))
Value = (|List| (|Symbol|))




)boot displayOperationsFromLisplib ['Pkg1]
)boot opList:= GETDATABASE('Pkg1,'OPERATIONALIST)
)boot opl:=REMDUP MSORT EQSUBSTLIST(nil,$FormalMapVariableList,opList)
)boot formatOperationAlistEntry(car opl) --> ERROR

-- simplified TEST, PKG1, PKG2

)abbrev domain TEST Test
Test(s:List Symbol):A==B where
T ==> OrderedVariableList s
A == CoercibleTo OutputForm with
foo: Integer -> %
B == T add
Rep:=T
foo(n) == (enumerate()$T).n

)abbrev package PKG1 Pkg1
Pkg1():A==B where
T ==> Test ['a,'b,'c]
A == with
bar : Integer -> T
B == T add
bar(n) == foo(n)$T

)abbrev package PKG2 Pkg2
Pkg2(s:List Symbol):A==B where
T ==> Test s
A == with
bar : Integer -> T
B == T add
bar(n) == foo(n)$T

-----------
; compilation finished in 0:00:00.010
------------------------------------------------------------------------
Pkg2 is now explicitly exposed in frame initial
Pkg2 will be automatically loaded when needed from
/Users/kfp/Desktop/work/spad/PKG2.NRLIB/PKG2

(2) -> )sh Pkg1
Pkg1 is a package constructor
Abbreviation for Pkg1 is PKG1
This constructor is exposed in this frame.
------------------------------- Operations --------------------------------
index out of range

(2) -> )sh Pkg2
Pkg2(s: List(Symbol)) is a package constructor
Abbreviation for Pkg2 is PKG2
This constructor is exposed in this frame.
------------------------------- Operations --------------------------------
bar : Integer -> Test(s)
--
You received this message because you are subscribed to the Google Groups "FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fricas-devel+***@googlegroups.com.
To post to this group, send email to fricas-***@googlegroups.com.
Visit this group at https://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.
Riccardo GUIDA
2018-07-19 09:15:46 UTC
Permalink
Hi
IIUC Test(SL) is a domain: is it legal in SPAD to use a domain in the LHS of a 'with' statement? (In Aldor it is not, "the LHS is an optional 'Category'-valued expression", see AldorUG sec 7.9)

ric
--
You received this message because you are subscribed to the Google Groups "FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fricas-devel+***@googlegroups.com.
To post to this group, send email to fricas-***@googlegroups.com.
Visit this group at https://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.
Kurt Pagani
2018-07-19 09:42:33 UTC
Permalink
Post by Riccardo GUIDA
Hi
IIUC Test(SL) is a domain: is it legal in SPAD to use a domain in the LHS of a
'with' statement?
No, it's not. This was just to provoke the error message (which has changed over
the versions, apparently). I'm supposing the "index 2 is too large" is somehow
related to the problem, but I couldn't find out yet who did the changes.

(In Aldor it is not, "the LHS is an optional 'Category'-valued
Post by Riccardo GUIDA
expression", see AldorUG sec 7.9)
ric
--
You received this message because you are subscribed to the Google Groups "FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fricas-devel+***@googlegroups.com.
To post to this group, send email to fricas-***@googlegroups.com.
Visit this group at https://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.
Waldek Hebisch
2018-07-21 20:21:29 UTC
Permalink
Post by Kurt Pagani
Hi Waldek
Post by Waldek Hebisch
Normal way to debug such problems is to use Lisp debugger, see
doc/debug.txt in the trunk.
)lisp (|coerceByFunction| '((|List| (|Symbol|)) WRAPPED |construct| (QUOTE |a|)
(QUOTE |b|) (QUOTE |c|)) '(|OutputForm|))
index out of range
Furthermore, objVal and objMode seem to be ok,
No. WRAPPED means that what follows should be actual value. What
we have is an unevaluated expression. AFAICS the core problem is
that parameters to domains sometimes are evaluated, sometimes
unevaluated. I am affraid that proper fix involves sizeable
rewrite to separate unevaluated parameters from evaluated ones.
This is essentially the same bug that Johannes and Ralf reported
earlier: if evaluated and unevaluated form of parameters is
the same than domain parameters work OK. If they are different
some routines will get parametes of unexpected form and fail.
--
Waldek Hebisch
--
You received this message because you are subscribed to the Google Groups "FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fricas-devel+***@googlegroups.com.
To post to this group, send email to fricas-***@googlegroups.com.
Visit this group at https://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.
Loading...