retract(s) missing ( Internal Error)

2 views
Skip to first unread message

Kurt Pagani

unread,
Apr 24, 2022, 10:26:47 AM4/24/22
to FriCAS - computer algebra system
Some code using "retract" breaks since V1.3.7. I couldn't figure out which revs might be accountable for. Any clues?

Here a minimal sample:

)abbrev domain TSTXDP TestXDP
TestXDP() : Exports == Implementation where
  R   ==> Expression Integer
  SYM ==> Symbol  
  XFS  ==> XFreeAlgebra(SYM,R)
  XDP  ==> XDistributedPolynomial(SYM,R)
  --
  Exports == Join( XFS) with
    makeIt : SYM -> %
  Implementation == XDP add
    Rep := XDP  
    makeIt(s:SYM):% == s::Rep

======
V1.3.5
======
; compilation finished in 0:00:00.008
------------------------------------------------------------------------
   TestXDP is now explicitly exposed in frame initial
   TestXDP will be automatically loaded when needed from
      /Users/kfp/Desktop/work/spad/pform/TSTXDP.NRLIB/TSTXDP

(1) -> )version

Value = "FriCAS 1.3.5 compiled at Mi, 17. Apr 2019 03:15:11"
(1) -> [X,Y,Z] := map(makeIt,[X,Y,Z])

   (1)  [X, Y, Z]
                                                          Type: List(TestXDP)
(2) ->  r:=X*Y^2*Z^4

           2 4
   (2)  X Y Z
                                                                Type: TestXDP
(3) -> TestXDP has RetractableTo FreeMonoid Symbol

   (3)  true
                                                                Type: Boolean
(4) -> retract r

           2 4
   (4)  X Y Z
                                                     Type: FreeMonoid(Symbol)
(5) ->

======
V1.3.7
======
; compilation finished in 0:00:00.004
------------------------------------------------------------------------
   TestXDP is now explicitly exposed in frame frame1
   TestXDP will be automatically loaded when needed from
      /tmp/TSTXDP.NRLIB/TSTXDP

(1) -> )version

Value = "FriCAS 2021-03-06 compiled at Fr 22 Apr 2022 15:24:45 CEST"
(1) -> [X,Y,Z] := map(makeIt,[X,Y,Z])

   (1)  [X, Y, Z]
                                                          Type: List(TestXDP)
(2) ->  r:=X*Y^2*Z^4

           2 4
   (2)  X Y Z
                                                                Type: TestXDP
(3) -> TestXDP has RetractableTo FreeMonoid Symbol

   (3)  true
                                                                Type: Boolean
(4) ->  retract r
Function:  retractIfCan : % -> Union(FreeMonoid(Symbol),"failed") is missing from domain: TestXDP
   Internal Error
   The function retractIfCan with signature
      (Union (FreeMonoid (Symbol)) failed)$ is missing from domain TestXDP

(4) -> )sh TestXDP

...
 retract : % -> FreeMonoid(Symbol)
 retractIfCan : % -> Union(FreeMonoid(Symbol),"failed")

Ralf Hemmecke

unread,
Apr 24, 2022, 11:14:48 AM4/24/22
to fricas...@googlegroups.com
Hi Kurt,

You do not need to create a new domain. It also fails to work with XDP
in the latest master.

Actually, if I am not wrong than "A has C" only tells you that C is
explicitly mentioned in the exports of A, but not whether there is an
actual implementation for C.

(1) -> Expression Integer has SemiRing

(1) true
(2) -> R ==> Expression Integer
(3) -> SYM ==> Symbol
(4) -> XDP ==> XDistributedPolynomial(SYM,R)
(5) -> [x::XDP for x in [X,Y,Z]]

(5) [X, Y, Z]
Type: List(XDistributedPolynomial(Symbol,Expression(Integer)))

(6) -> [a,b,c] := [x::XDP for x in [X,Y,Z]]

(6) [X, Y, Z]
Type: List(XDistributedPolynomial(Symbol,Expression(Integer)))
(7) -> a

(7) X
Type: XDistributedPolynomial(Symbol,Expression(Integer))
(8) -> r := a*b^2*c^4

2 4
(8) X Y Z
Type: XDistributedPolynomial(Symbol,Expression(Integer))
(9) -> retract r
Function: retractIfCan : % -> Union(FreeMonoid(Symbol),"failed") is
missing from domain: XDistributedPolynomial(Symbol,Expression(Integer))
Internal Error
The function retractIfCan with signature
(Union (FreeMonoid (Symbol)) failed)$ is missing from domain
XDistributedPolynomial(Symbol)(Expression (Integer))

(9) -> R

(9) Expression(Integer)

(10) -> R has SemiRing

(10) true

(11) -> XDP has RetractableTo(FreeMonoid SYM)

(11) true

However, looking down the implementation chain tells me that retract
should be implemented through FreeModule(R,FreeMonoid SYM). But we have

(12) -> F := FreeModule(R,FreeMonoid SYM)

(12) FreeModule(Expression(Integer),FreeMonoid(Symbol))
(13) -> F has RetractableTo(FreeMonoid SYM)

(13) true

(16) -> s := 'x::Symbol

(16) x
Type: Symbol
(17) -> sf := s :: F

(17) x
Type: FreeModule(Expression(Integer),FreeMonoid(Symbol))
(18) -> retract sf

(18) x
Type: FreeMonoid(Symbol)

So indeed, your detected error is weird.
In fact, when you enter XDistributedPolynomial into HyperDoc browse, add
the parameters vl=Symbol and R=Expression Integer, click on Operations
and then on Implementation, it also tell you that retractIfCan is
nowhere implemented.

My suspicion is that it has something to do with the conditional
implementation of retract in FreeModule. I faintly remember that I once
had a similar issue.

Looks like someone must use "git bisect run" to find out which commit
causes the issue.

Ralf

Ralf

Kurt Pagani

unread,
Apr 24, 2022, 11:31:08 AM4/24/22
to fricas...@googlegroups.com
On 24.04.2022 17:14, Ralf Hemmecke wrote:
> Hi Kurt,
>
> You do not need to create a new domain. It also fails to work with XDP in the
> latest master.

I was aware about that, however, the strange thing is that this failed already
in version 1.3.5.


(2) -> [x,y]:=[s::XDistributedPolynomial(Symbol,EXPR INT) for s in [x,y]]

(2) [x, y]
Type: List(XDistributedPolynomial(Symbol,Expression(Integer)))
(3) -> x*y^3

3
(3) x y
Type: XDistributedPolynomial(Symbol,Expression(Integer))
(4) -> retract %

>> Error detected within library code:
FM1.retract impossible

(4) -> )version

Value = "FriCAS 1.3.5 compiled at Mi, 17. Apr 2019 03:15:11"
(4) ->

(4) -> retractIfCan(x*y^5);

Type: Union("failed",...)
(5) -> retractIfCan(x);

Type: Union("failed",...)

>
> Actually, if I am not wrong than "A has C" only tells you that C is explicitly
> mentioned in the exports of A, but not whether there is an actual implementation
> for C.

Yes, I also think so, however, when it worked, as it certainly did in 1.3.5,
then you wouldn't waste much time ;)
Thanks!
Kurt
>
> Ralf
>
> Ralf
>

Ralf Hemmecke

unread,
Apr 24, 2022, 11:38:27 AM4/24/22
to fricas...@googlegroups.com
>> You do not need to create a new domain. It also fails to work with XDP in the
>> latest master.
>
> I was aware about that, however, the strange thing is that this failed already
> in version 1.3.5.

Something I don't understand... you claim that retract$TestXDP works in
1.3.5 although retract in XDP is claimed to be not implemented as you
show below. How can that be?

Anyway, for git-bisect it would be good to know FriCAS commit where
retract$XDP **is** actually working as expected. I guess that fixing XDP
will also fix TestXDP.

Ralf

Kurt Pagani

unread,
Apr 24, 2022, 11:50:13 AM4/24/22
to fricas...@googlegroups.com


On 24.04.2022 17:38, Ralf Hemmecke wrote:
>>> You do not need to create a new domain. It also fails to work with XDP in the
>>> latest master.
>>
>> I was aware about that, however, the strange thing is that this failed already
>> in version 1.3.5.
>
> Something I don't understand... you claim that retract$TestXDP works in 1.3.5
> although retract in XDP is claimed to be not implemented as you show below. How
> can that be?

That's the question here :) -- a mystery @moment.

Ralf Hemmecke

unread,
Apr 24, 2022, 11:52:51 AM4/24/22
to fricas...@googlegroups.com
>> Something I don't understand... you claim that retract$TestXDP works in 1.3.5
>> although retract in XDP is claimed to be not implemented as you show below. How
>> can that be?
>
> That's the question here :) -- a mystery @moment.

Obviously something where only Wizard Waldek can help. ;-)

Ralf
Reply all
Reply to author
Forward
0 new messages