axiom-developer
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Axiom-developer] Another strange coercion


From: Franz Lehner
Subject: [Axiom-developer] Another strange coercion
Date: Mon, 13 Aug 2007 19:57:07 +0200 (CEST)

Hello,

There are many easy examples of this when you use the Axiom interpreter.
Perhaps the following is related:

Trying to implement free products of monoids
FreeProductMonoid(M1:Monoid,M2:Monoid)
(see attachment, not very elegant, but I don't know how to avoid "mixed lists" otherwise). I am stuck at the following problem: There are two converters

coerce:M1 -> %
coerce:M2 -> %

but somehow always the first converter is called,
in the order where they are found in the source file,
leading to strange results:


(1) -> Z2:=CyclicGroup(2,'a)

   (1)  CyclicGroup(2,a)
                                                       Type: Domain
(2) -> Z3:=CyclicGroup(3,'b)

   (2)  CyclicGroup(3,b)
                                                       Type: Domain
(3) -> G:=FreeProductMonoid(Z2,Z3)

   (3)  FreeProductMonoid(CyclicGroup(2,a),CyclicGroup(3,b))
                                                       Type: Domain
(4) -> a1:=a::Z2

   (4)  a
                                                       Type: CyclicGroup(2,a)
(5) -> b1:=b::Z3

   (5)  b
                                                       Type: CyclicGroup(3,b)
(6) -> a2:=a1::G

   (6)  a
                   Type: FreeProductMonoid(CyclicGroup(2,a),CyclicGroup(3,b))
(7) -> b2:=b1::G

   (7)  a
                   Type: FreeProductMonoid(CyclicGroup(2,a),CyclicGroup(3,b))

(8) -> b2a:= (b1^2) ::G

         2
   (8)  a
                   Type: FreeProductMonoid(CyclicGroup(2,a),CyclicGroup(3,b))


(9) -> b2a * 1::G

   (9)  1

(10) -> b::Z2

   >> System error:
   wrong symbol


Especially (8) is pretty strange. (9) shows that indeed b made it into M1 and is the identity element. (10) shows that coercion in CyclicGroup filters out the wrong symbols as it should. What am I missing? Somehow the interpreter is confused by two almost equal signatures (both M1 and M2 are Monoids). Is this forbidden?
Renaming the converters to coerce1 and coerce2 makes it work.

regards
Franz

Attachment: free.as
Description: Text document

Attachment: cyclic.as
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]