|
|
|
last edited 18 years ago by Bill Page |
| 1 2 3 4 5 6 7 8 | ||
|
Editor: Bill Page
Time: 2008/07/27 14:02:32 GMT-7 |
||
| Note: ducks | ||
changed: - During the Aldor/Axiom Workshop 2008 at RISC in one of his presentations Stephen Watt began with: Q: When is a duck not a Duck? A: When it is an AbelianDuck! This is in reference to the problem of defining appropriate categories for domains such as 'Integer' which have a monoid consisting of (*,1) as well as a monoid consisting of (+,0) (or more specifically, a commutative group which is contained in such a monoid). The issue is: Why should we be required to use different names for categories like 'Monoid' to mean just (*,1) and 'AbelianGroup' to mean (+,0). But an AbelianDuck really is a Duck! Here is another (still unsuccessful) attempt to express this in SPAD code. The error during compile suggests a compiler error, but the specifications of the language are not clear on exactly whether this sort of construction is really intended to work. \begin{spad} )abbrev category ASSOC Associative -- m(m(a,b),c) = m(a,m(b,c)) Associative(m:Symbol):Category == with m:(%,%) -> % )abbrev category COM Commutative -- m(a,b) = m(b,a) Commutative(m:Symbol):Category == with m:(%,%) -> % )abbrev category ID Identity -- m(u,a)=a and m(a,u)=a Identity(u:Symbol,m:Symbol):Category == Commutative(m) with u: () -> % )abbrev category INV Inverse -- m(inv(a),a) = u and m(a,inv(a)) = u Inverse(m:Symbol,inv:Symbol,u:Symbol):Category == Join(Commutative(m),Identity(u)) with inv: % -> % )abbrev category DIST Distributes -- m(a,s(b,c)) = s(m(a,b),m(a,c)) -- m(s(a,b),c) = s(m(a,c),m(b,c)) Distributes(m,s):Category == with nil )abbrev category MONOID Monoid Monoid(m:Symbol,u:Symbol): Category == Join(Associative(m),Identity(u)) )abbrev category GROUP Group Group(m:Symbol,inv:Symbol,u:Symbol): Category == Join(Monoid(m,u),Inverse(m,inv,u)) )abbrev category ABELG AbelianGroup AbelianGroup(m:Symbol,inv:Symbol,u:Symbol): Category == Joint(Group(m,inv,u),Commutative(m)) )abbrev category RING Ring Ring(s:Symbol,inv:Symbol,z:Symbol, m:Symbol,u:Symbol): Category == Join(AbelianGroup(s,inv,z),Monoid(m,u),Distributes(m,s)) \end{spad} \begin{axiom} )sh Ring("+","-","0",*,"1") Ring("+","-","0","*","1") has commutative("+") \end{axiom} Let's try this ... \begin{axiom} )sh Ring(a,b,c,d,e) Ring(a,b,c,d,e) has commutative(a) \end{axiom} Interesting! Is it somewhere written that "has" can have a category as its first argument? OK, we are going to implement... \begin{spad} )abbrev domain MYINT MyInteger MyInteger: Ring(a,b,c,d,e) == add Rep:=Integer a(x: %, y: %): % == x b(x: %): % == x c(): % == 0 pretend % d(x: %, y: %): % == x e(): % == 0 pretend % \end{spad}
During the Aldor/Axiom Workshop 2008 at RISC in one of his presentations Stephen Watt began with:
Q: When is a duck not a Duck? A: When it is an AbelianDuck?!
This is in reference to the problem of defining appropriate
categories for domains such as Integer which have a monoid
consisting of (*,1) as well as a monoid consisting of (+,0)
(or more specifically, a commutative group which is contained
in such a monoid). The issue is: Why should we be required to
use different names for categories like Monoid to mean just
(*,1) and AbelianGroup to mean (+,0).
But an AbelianDuck? really is a Duck!
Here is another (still unsuccessful) attempt to express this in SPAD code. The error during compile suggests a compiler error, but the specifications of the language are not clear on exactly whether this sort of construction is really intended to work.
(1) -> <spad>
)abbrev category ASSOC Associative -- m(m(a,b), c) = m(a, m(b, c)) Associative(m:Symbol):Category == with m:(%, %) -> %
)abbrev category COM Commutative -- m(a,b) = m(b, a) Commutative(m:Symbol):Category == with m:(%, %) -> %
)abbrev category ID Identity -- m(u,a)=a and m(a, u)=a Identity(u:Symbol, m:Symbol):Category == Commutative(m) with u: () -> %
)abbrev category INV Inverse -- m(inv(a),a) = u and m(a, inv(a)) = u Inverse(m:Symbol, inv:Symbol, u:Symbol):Category == Join(Commutative(m), Identity(u)) with inv: % -> %
)abbrev category DIST Distributes -- m(a,s(b, c)) = s(m(a, b), m(a, c)) -- m(s(a, b), c) = s(m(a, c), m(b, c)) Distributes(m, s):Category == with nil
)abbrev category MONOID Monoid Monoid(m:Symbol,u:Symbol): Category == Join(Associative(m), Identity(u))
)abbrev category GROUP Group Group(m:Symbol,inv:Symbol, u:Symbol): Category == Join(Monoid(m, u), Inverse(m, inv, u))
)abbrev category ABELG AbelianGroup AbelianGroup(m:Symbol,inv:Symbol, u:Symbol): Category == Joint(Group(m, inv, u), Commutative(m))
)abbrev category RING Ring Ring(s:Symbol,inv:Symbol, z:Symbol, m:Symbol, u:Symbol): Category == Join(AbelianGroup(s, inv, z), Monoid(m, u), Distributes(m, s))</spad>
Compiling FriCAS source code from file
/var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/9120812264571396571-25px001.spad
using system compiler.
ASSOC abbreviates category Associative
------------------------------------------------------------------------
initializing NRLIB ASSOC for Associative
compiling into NRLIB ASSOC
Time: 0 SEC.
finalizing NRLIB ASSOC
Processing Associative for Browser database:
--->-->Associative(constructor): Not documented!!!!
--->-->Associative((m (% % %))): Not documented!!!!
--->-->Associative: Missing Description
; compiling file "/var/aw/var/LatexWiki/ASSOC.NRLIB/ASSOC.lsp" (written 23 OCT 2026 08:36:10 AM):
; wrote /var/aw/var/LatexWiki/ASSOC.NRLIB/ASSOC.fasl
; compilation finished in 0:00:00.004
------------------------------------------------------------------------
Associative is now explicitly exposed in frame initial
Associative will be automatically loaded when needed from
/var/aw/var/LatexWiki/ASSOC.NRLIB/ASSOC
COM abbreviates category Commutative
------------------------------------------------------------------------
initializing NRLIB COM for Commutative
compiling into NRLIB COM
Time: 0 SEC.
finalizing NRLIB COM
Processing Commutative for Browser database:
--->-->Commutative(constructor): Not documented!!!!
--->-->Commutative((m (% % %))): Not documented!!!!
--->-->Commutative: Missing Description
; compiling file "/var/aw/var/LatexWiki/COM.NRLIB/COM.lsp" (written 23 OCT 2026 08:36:10 AM):
; wrote /var/aw/var/LatexWiki/COM.NRLIB/COM.fasl
; compilation finished in 0:00:00.000
------------------------------------------------------------------------
Commutative is now explicitly exposed in frame initial
Commutative will be automatically loaded when needed from
/var/aw/var/LatexWiki/COM.NRLIB/COM
ID abbreviates category Identity
------------------------------------------------------------------------
initializing NRLIB ID for Identity
compiling into NRLIB ID
;;; *** |Identity| REDEFINED
Time: 0 SEC.
finalizing NRLIB ID
Processing Identity for Browser database:
--->-->Identity(constructor): Not documented!!!!
--->-->Identity((u (%))): Not documented!!!!
--->-->Identity: Missing Description
; compiling file "/var/aw/var/LatexWiki/ID.NRLIB/ID.lsp" (written 23 OCT 2026 08:36:10 AM):
; wrote /var/aw/var/LatexWiki/ID.NRLIB/ID.fasl
; compilation finished in 0:00:00.000
------------------------------------------------------------------------
>> System error:
Error evaluating a form:
Too few arguments in (|Commutative|) to satisfy lambda list (t#1 t#2).)sh Ring("+", "-", "0", *, "1")
The constructor Ring takes 0 arguments and you have given 5 .
Let's try this ...
)sh Ring(a,b, c, d, e)
The constructor Ring takes 0 arguments and you have given 5 .
Interesting! Is it somewhere written that "has" can have a category as its first argument?
OK, we are going to implement...
)abbrev domain MYINT MyInteger MyInteger: Ring(a,b, c, d, e) == add Rep:=Integer a(x: %, y: %): % == x b(x: %): % == x c(): % == 0 pretend % d(x: %, y: %): % == x e(): % == 0 pretend %
Compiling FriCAS source code from file
/var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/4007632824524312372-25px004.spad
using system compiler.
MYINT abbreviates domain MyInteger
------------------------------------------------------------------------
initializing NRLIB MYINT for MyInteger
compiling into NRLIB MYINT
>> System error:
invalid number of arguments: 5