spad )abbrev category MM MyMonoid )if false -- Does not work now Monoid(m:Symbol, spad Compiling FriCAS source code from file /var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/4564540169107216349-25px001.spad using old system compiler. MM abbreviates category MyMonoid fricas )sh Ring(+, Let's try this ... fricas )sh Ring(a, Interesting! Is it somewhere written that "has" can have a category as its first argument? OK, we are going to implement... spad )abbrev domain MYINT MyInteger MyInteger: Ring(a, spad Compiling FriCAS source code from file /var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/4007632824524312372-25px004.spad using old system compiler. MYINT abbreviates domain MyInteger ------------------------------------------------------------------------ initializing NRLIB MYINT for MyInteger compiling into NRLIB MYINT Oops, that's not so easy. Have I made some error? (You originally wrote begin{axiom} but this is spad code. `Monoid` , we are effectively creating to different things with the same name, but different types. We have an `m` of type `Symbol` , and another one of type `(%,%)->%` . As soon as we add a default implementation, this mistake surfaces:
spad )abbrev category MYMON MyMonoid MyMonoid(m:Symbol): Category == with m:(%, spad Compiling FriCAS source code from file /var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/1161784151565736029-25px005.spad using old system compiler. MYMON abbreviates category MyMonoid ------------------------------------------------------------------------ initializing NRLIB MYMON for MyMonoid compiling into NRLIB MYMON spad )abbrev domain WORD Word Word(c:Symbol): MyMonoid(c) with coerce:String -> % coerce:% -> OutputForm == add Rep := String coerce(a:String):% == a pretend % coerce(x:%):OutputForm == message(x pretend String)$OutputForm c(a:%, spad Compiling FriCAS source code from file /var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/4459260466707001674-25px006.spad using old system compiler. WORD abbreviates domain Word ------------------------------------------------------------------------ initializing NRLIB WORD for Word compiling into NRLIB WORD compiling exported coerce : String -> $ WORD;coerce;S$;1 is replaced by a Time: 0 SEC. fricas )sh Word fricas )sh Word("p"::Symbol)
Type: Word(p)fricas w2:="b"::Word("p"::Symbol)
Type: Word(p)fricas p(w1, What we really would like to have would be something along the lines of: spad )abbrev category MYMON1 MyMonoid1 MyMonoid1(S:SetCategory, spad Compiling FriCAS source code from file /var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/6825787861264248532-25px008.spad using old system compiler. MYMON1 abbreviates category MyMonoid1 ------------------------------------------------------------------------ initializing NRLIB MYMON1 for MyMonoid1 compiling into NRLIB MYMON1 fricas )sh MyMonoid1 fricas )set functions compile on
Type: ((String,fricas m1("aaa",
Type: Stringfricas )sh MyMonoid1(String, Type: Voidfricas m2("aaa", fricas Compiling function m2 with type (String,
Type: Stringfricas )sh MyMonoid1(String, Then: Word: MyMonoid1(String,(a:String,b:String):String+->concat(a,b)) with coerce: String -> % == add Rep := String coerce(a: String): % == a c(a:%, b:%):% == concat(a::Rep, b::Rep) However, there are two problems here: - it is not possible to refer to the category to be defined in the parameter, as in
`MyMonoid(m: (%,%)-> %)` - it is not possible to refer to an operation which is not yet defined as in
`Word: MyMonoid(c) with`
Martin scope of names in default implementation of categories --Bill Page, Thu, 02 Mar 2006 09:42:18 -0600 replyUnfortunately, this won't work. For example in the above definition of Monoid, we are effectively creating to different things with the same name, but different types. We have an m of type Symbol, and another one of type (%,%)->%. I agree that there is a scope issue here. Perhaps it comes from
the idea of allowing default implementation as part of the category
definition. But I think the proper semantics are quite easy to define.
The exports need to have priority over the parameters. The So I think this is a compiler error. Based on an idea posted to this page by Martin Rubey, I have constructed what I think is a good facsimile of a generic monoid. I think think that this construction is only possible in Aldor.The idea is basically to specify a monoid as a tuple in the
usual manner, consisting of a set This is rather different that the notion that we started with in this thread - in fact more or less the opposite: from any more complex domain we can extract the monoid part. Of course this is fundamentally very simple, just as it should be. :) aldor #include "axiom" aldor Compiling FriCAS source code from file /var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/mymonoid.as using AXIOM-XL compiler and options -O -Fasy -Fao -Flsp -laxiom -Mno-ALDOR_W_WillObsolete -DAxiom -Y $AXIOM/algebra -I $AXIOM/algebra Use the system command )set compiler args to change these options. The )library system command was not called after compilation. This is how the fricas )sh MyMonoid fricas )sh MyMonoid(String, fricas )sh MyMonoid(List INT, Here is Martin Rubey's String monoid example: fricas w1:="a"::MyMonoid(String, And of course we can construct a large number of other examples. fricas i1:=[1,
Type: Polynomial(Integer)fricas i1*i1
Type: Polynomial(Integer)fricas i1^3
Type: Polynomial(Integer)fricas i1*1$MyMonoid(List INT, fricas i1:=10::MyMonoid(INT,
Type: Polynomial(Integer)fricas i1*i1
Type: Polynomial(Integer)fricas i1^0
Type: Polynomial(Integer)fricas i1*1$MyMonoid(INT, fricas i1:=10.1::MyMonoid(Float,
Type: Polynomial(Integer)fricas i1*i1
Type: Polynomial(Integer)fricas i1^4
Type: Polynomial(Integer)fricas i1*1$MyMonoid(Float, Now try to define a group. aldor #include "axiom" #library MyMonoid "mymonoid.ao"; import from MyMonoid; aldor Compiling FriCAS source code from file /var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/mygroup.as using AXIOM-XL compiler and options -O -Fasy -Fao -Flsp -laxiom -Mno-ALDOR_W_WillObsolete -DAxiom -Y $AXIOM/algebra -I $AXIOM/algebra Use the system command )set compiler args to change these options. The )library system command was not called after compilation. This is how the fricas )sh MyGroup fricas )sh MyGroup(INT, For example: fricas x:=3::MyGroup(INT,
Type: Polynomial(Integer)`MyRing` . Any domain in `MyRing` should work without unnecessary package calls in the Interpreter. All this mechanism did was passing a function `m` to constructors, here to be used as the monoid categorically defined multiplication. This technique has been used before, in Axiom, in `GDMP` . The notation in an Interpreter session is still `*` , the operator declared in `MyMonoid` . So even though we have `MyMonoid(INT,+,0)` and we can compute using `i1*i2` to really get the sum of `i1` and `i2` , this is not using `+` notation. Notice also that `MyGroup` should have been implemented as a category constructor. In `)sh MyGroup` , the group operation is `*` , the unit is `1` and the inverse is `-` (which is incompatible with `*` and wrong, since a group should not be commutative in general). But these last two comments are minor quibbles and easily corrected.
I indicated before that I believe one needs to make some deeper changes to implement inheritance that would support notational changes in a way such that multiple inheritance of I am more interested in the William William, it seems to me that you are easilynot impressed ;)
But thanks for your comments.
I agree that the second half of this page implements a different structure than the first half - I said as much above. It is in a formal sense the exact opposite thing. But opposites can be useful. I am working out the details here because I am hoping that in the end we can see the issue of inheritance more precisely as the dual to this construction. The point here is that MyGroup(INT,+,-,0) >-----> INT with *, ~, 1 with +, -, 0, *, /, 1, ... In categorical terms both (Note that I changed the notation for inverse in
Inheritance does require something similiar: MyInteger: Join(Group(%,+,-,0), Monoid(%, *, 1), ... with *, ~, 1 with *, 1 In this case the categories The
I am still thinking about how best to encode these sort of axioms,
so the Stay tuned to this channel ... Define an Abelian (commutative) group: aldor #include "axiom" #library MyMonoid "mymonoid.ao"; import from MyMonoid; #library MyGroup "mygroup.ao"; import from MyGroup; aldor Compiling FriCAS source code from file /var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/myabeliangroup.as using AXIOM-XL compiler and options -O -Fasy -Fao -Flsp -laxiom -Mno-ALDOR_W_WillObsolete -DAxiom -Y $AXIOM/algebra -I $AXIOM/algebra Use the system command )set compiler args to change these options. The )library system command was not called after compilation. MyAbelianMonoid? is a MyMonoid?. MyAbelianGroup? is a MyGroup? and a MyMonoid?. fricas )sh MyAbelianMonoid fricas )sh MyMonoid(MyAbelianMonoid(INT, fricas )sh MyAbelianGroup fricas )sh MyGroup(MyAbelianGroup(INT, fricas )sh MyMonoid(MyAbelianGroup(INT, Define a ring: aldor #include "axiom" #library MyMonoid "mymonoid.ao"; import from MyMonoid; #library MyGroup "mygroup.ao"; import from MyGroup; #library MyAbelianGroup "myabeliangroup.ao"; import from MyAbelianGroup; aldor Compiling FriCAS source code from file /var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/4246596118391608395-25px022.as using AXIOM-XL compiler and options -O -Fasy -Fao -Flsp -laxiom -Mno-ALDOR_W_WillObsolete -DAxiom -Y $AXIOM/algebra -I $AXIOM/algebra Use the system command )set compiler args to change these options. The )library system command was not called after compilation. It looks like this. fricas )sh MyRing Integer is a MyRing?. fricas x3:=3::MyRing(Integer,
Type: Polynomial(Integer)fricas w3:=x2+z3
Type: Polynomial(Integer)Martin Rubey discovered a way to use the Aldor |

...--kratt6, Thu, 02 Mar 2006 08:46:49 -0600 reply