login  home  contents  what's new  discussion  bug reports     help  links  subscribe  changes  refresh  edit

Edit detail for SandBoxCommutativeCategory revision 6 of 11

1 2 3 4 5 6 7 8 9 10 11
Editor: Bill Page
Time: 2008/07/26 06:24:29 GMT-7
Note: Re: nothing to do with the actual names of operations

added:

From BillPage Sat Jul 26 06:24:22 -0700 2008
From: Bill Page
Date: Sat, 26 Jul 2008 06:24:22 -0700
Subject: Re: nothing to do with the actual names of operations
Message-ID: <20080726062422-0700@axiom-wiki.newsynthesis.org>

It is equally true that attributes like commutative("*") have nothing
to do with the actual names of operations. So I think that this use
of categories is functionally equivalent to the use of attributes.

yixin.cao, I do not see anything wrong with writing,
for example::

  Dpackage(): Join(Commutative("f1"),Commutative("f3", ...) with
    f1:(D,D)->D
    f2:(D,D)->D
    f3:(D,D)->D

To me this a reasonable encoding of the idea that
"f1 and f3 are commutative, while f2 is not". But of course it
is only referring to the symbols/strings "f1" etc. and not the
actual functions.

I think it is possible to try something a little more ambitious
that at least appears to relate to the names of functions.
\begin{spad}
)abbrev category COM2 Commutative2
Commutative2(T:Type,s:Symbol):Category == with
  s:(T,T) -> T
\end{spad}

\begin{axiom}
)show COM2(Integer,"*")
)show COM2(Float,"+")
\end{axiom}

\begin{spad}
)abbrev domain COMD2 CommutativeDomain2
CommutativeDomain2(): Commutative2(%,_*) with
    coerce:%->OutputForm
  == add
    coerce(x)== x pretend OutputForm
    x * x == x
\end{spad}

\begin{axiom}
)sh CommutativeDomain2
CommutativeDomain2 has Commutative2(CommutativeDomain2,"*")
CommutativeDomain2 has Commutative2(CommutativeDomain2,"+")
\end{axiom}

Now, I **do** consider the fact that this works rather amazing!

Can the attribute commutative("*") be replaced with a category definition like

spad
)abbrev category COM Commutative Commutative(n:String):Category == with nil
spad
   Compiling FriCAS source code from file 
      /var/zope2/var/LatexWiki/4589802368271964260-25px001.spad using 
      old system compiler.
   COM abbreviates category Commutative 
------------------------------------------------------------------------
   initializing NRLIB COM for Commutative 
   compiling into NRLIB COM 
;;; *** |Commutative| REDEFINED Time: 0.01 SEC.
finalizing NRLIB COM Processing Commutative for Browser database: --->-->Commutative(constructor): Not documented!!!! --->-->Commutative(): Missing Description ------------------------------------------------------------------------ Commutative is now explicitly exposed in frame initial Commutative will be automatically loaded when needed from /var/zope2/var/LatexWiki/COM.NRLIB/code

spad
)abbrev domain COMD CommutativeDomain CommutativeDomain(): Commutative("*") with coerce:%->OutputForm == add coerce(x)== x pretend OutputForm
spad
   Compiling FriCAS source code from file 
      /var/zope2/var/LatexWiki/5314528024349234223-25px002.spad using 
      old system compiler.
   COMD abbreviates domain CommutativeDomain 
------------------------------------------------------------------------
   initializing NRLIB COMD for CommutativeDomain 
   compiling into NRLIB COMD 
   compiling exported coerce : $ -> OutputForm
      COMD;coerce;$Of;1 is replaced by x 
Time: 0 SEC.
(time taken in buildFunctor: 0)
;;; *** |CommutativeDomain| REDEFINED
;;; *** |CommutativeDomain| REDEFINED Time: 0 SEC.
Cumulative Statistics for Constructor CommutativeDomain Time: 0 seconds
finalizing NRLIB COMD Processing CommutativeDomain for Browser database: --->-->CommutativeDomain((coerce ((OutputForm) %))): Not documented!!!! --->-->CommutativeDomain(constructor): Not documented!!!! --->-->CommutativeDomain(): Missing Description ------------------------------------------------------------------------ CommutativeDomain is now explicitly exposed in frame initial CommutativeDomain will be automatically loaded when needed from /var/zope2/var/LatexWiki/COMD.NRLIB/code

axiom
CommutativeDomain has Commutative("*")
LatexWiki Image(1)
Type: Boolean
axiom
CommutativeDomain has Commutative("+")
LatexWiki Image(2)
Type: Boolean

That is amazing. As demonstrated above, CommutativeDomain is just declared to be Commutative("*") even though there is no exported operation *.

In fact, what is demonstrated here has nothing to do with the actual names of operations exported by a domain, but just with the declaration that CommutativeDomain is of category Commutative("*").

Since above the definition says Commutative(n:Symbol) there should be double quotes around the *.

Is this the really problem? --yixin.cao, Sat, 26 Jul 2008 00:20:36 -0700 reply
Even such a category is possible, so we can define domain D:Join(Commutative(*),Commutative(+),Commutative(max),....). But when I need to write a algorithm package to do some computations on that domain, in which I have several new functions(supposed all (D,D)->D), say, f1, f2, f3, how do I say f1 and f3 are commutative, while f2 is not?

One choice is adding properties inference with static analysis into the compiler(is there a possibility this inference algorithm be designed perfect?). Another is to define the property commutativity directly on the function *, instead of the domain. Or both.

Re: nothing to do with the actual names of operations --Bill Page, Sat, 26 Jul 2008 06:24:22 -0700 reply
It is equally true that attributes like commutative("*") have nothing to do with the actual names of operations. So I think that this use of categories is functionally equivalent to the use of attributes.

yixin.cao, I do not see anything wrong with writing, for example:

  Dpackage(): Join(Commutative("f1"),Commutative("f3", ...) with
    f1:(D,D)->D
    f2:(D,D)->D
    f3:(D,D)->D

To me this a reasonable encoding of the idea that "f1 and f3 are commutative, while f2 is not". But of course it is only referring to the symbols/strings "f1" etc. and not the actual functions.

I think it is possible to try something a little more ambitious that at least appears to relate to the names of functions.

spad
)abbrev category COM2 Commutative2 Commutative2(T:Type,s:Symbol):Category == with s:(T,T) -> T
spad
   Compiling FriCAS source code from file 
      /var/zope2/var/LatexWiki/7119483407360057115-25px001.spad using 
      old system compiler.
   COM2 abbreviates category Commutative2 
------------------------------------------------------------------------
   initializing NRLIB COM2 for Commutative2 
   compiling into NRLIB COM2 
;;; *** |Commutative2| REDEFINED Time: 0 SEC.
finalizing NRLIB COM2 Processing Commutative2 for Browser database: --->-->Commutative2((s (T$ T$ T$))): Not documented!!!! --->-->Commutative2(constructor): Not documented!!!! --->-->Commutative2(): Missing Description ------------------------------------------------------------------------ Commutative2 is now explicitly exposed in frame initial Commutative2 will be automatically loaded when needed from /var/zope2/var/LatexWiki/COM2.NRLIB/code

axiom
)show COM2(Integer,"*")
Commutative2(Integer,*) is a category constructor. Abbreviation for Commutative2 is COM2 This constructor is exposed in this frame. Issue )edit /var/zope2/var/LatexWiki/7119483407360057115-25px001.spad to see algebra source code for COM2
------------------------------- Operations --------------------------------
?*? : (Integer,Integer) -> Integer
axiom
)show COM2(Float,"+")
Commutative2(Float,+) is a category constructor. Abbreviation for Commutative2 is COM2 This constructor is exposed in this frame. Issue )edit /var/zope2/var/LatexWiki/7119483407360057115-25px001.spad to see algebra source code for COM2
------------------------------- Operations --------------------------------
?+? : (Float,Float) -> Float

spad
)abbrev domain COMD2 CommutativeDomain2 CommutativeDomain2(): Commutative2(%,_*) with coerce:%->OutputForm == add coerce(x)== x pretend OutputForm x * x == x
spad
   Compiling FriCAS source code from file 
      /var/zope2/var/LatexWiki/8953674606596896921-25px003.spad using 
      old system compiler.
   COMD2 abbreviates domain CommutativeDomain2 
------------------------------------------------------------------------
   initializing NRLIB COMD2 for CommutativeDomain2 
   compiling into NRLIB COMD2 
   compiling exported coerce : $ -> OutputForm
      COMD2;coerce;$Of;1 is replaced by x 
Time: 0.01 SEC.
compiling exported * : ($,$) -> $ COMD2;*;3$;2 is replaced by x Time: 0 SEC.
(time taken in buildFunctor: 0)
;;; *** |CommutativeDomain2| REDEFINED
;;; *** |CommutativeDomain2| REDEFINED Time: 0 SEC.
Cumulative Statistics for Constructor CommutativeDomain2 Time: 0.01 seconds
finalizing NRLIB COMD2 Processing CommutativeDomain2 for Browser database: --->-->CommutativeDomain2((coerce ((OutputForm) %))): Not documented!!!! --->-->CommutativeDomain2(constructor): Not documented!!!! --->-->CommutativeDomain2(): Missing Description ------------------------------------------------------------------------ CommutativeDomain2 is now explicitly exposed in frame initial CommutativeDomain2 will be automatically loaded when needed from /var/zope2/var/LatexWiki/COMD2.NRLIB/code

axiom
)sh CommutativeDomain2
CommutativeDomain2 is a domain constructor Abbreviation for CommutativeDomain2 is COMD2 This constructor is exposed in this frame. Issue )edit /var/zope2/var/LatexWiki/8953674606596896921-25px003.spad to see algebra source code for COMD2
------------------------------- Operations -------------------------------- ?*? : (%,%) -> % coerce : % -> OutputForm
CommutativeDomain2 has Commutative2(CommutativeDomain2,"*")
LatexWiki Image(1)
Type: Boolean
axiom
CommutativeDomain2 has Commutative2(CommutativeDomain2,"+")
LatexWiki Image(2)
Type: Boolean

Now, I do consider the fact that this works rather amazing!