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

Edit detail for SubDomain revision 2 of 7

1 2 3 4 5 6 7
Editor: Bill Page
Time: 2008/09/18 13:36:53 GMT-7
Note: Domain and SubDomain

added:
'Domain' is a domain whose values are all domains.

changed:
-'Domain' is a domain whose values are all domains. For
-example:
For example:

added:

Unfortunately the original Axiom library did not include
definitions of these domains.

\begin{axiom}
[Integer,PrimeField(3)]
\end{axiom}

\begin{axiom}
[Ring,Field]
\end{axiom}

However OpenAxiom has implemented 'Domain' and replaced
'SubDomain Domain' with 'Category'. Here we try to provide
something similar for FriCAS.
\begin{spad}
)abbrev domain DOMAIN Domain
Domain():SetCategory with CoercibleTo(InputForm)
  == add
    coerce(x:%):OutputForm ==
      n:SExpression:=devaluate(x)$Lisp
      #n=1 => car(n) pretend OutputForm
      n pretend OutputForm
    x = y ==
      devaluate(x)$Lisp = devaluate(y)$Lisp
    coerce(x:%):InputForm ==
      devaluate(x)$Lisp
\end{spad}

\begin{spad}
)abbrev domain SUBDOM SubDomain
SubDomain(D:Domain):SetCategory with CoercibleTo(InputForm)
  == add
    coerce(x:%):OutputForm ==
      n:SExpression:=devaluate(x)$Lisp
      #n=1 => car(n) pretend OutputForm
      n pretend OutputForm
    x = y ==
      devaluate(x)$Lisp = devaluate(y)$Lisp
    coerce(x:%):InputForm ==
      devaluate(x)$Lisp
\end{spad}

\begin{axiom}
[Integer,PrimeField(3)]
%.1
\end{axiom}

\begin{axiom}
[Ring,Field,IntegerNumberSystem]
\end{axiom}

Although it is exported:
\begin{axiom}
)sh Domain
\end{axiom}
unfortunately the interpreter still does not seem to be
able to call the 'coerce' to 'InputForm' function even
though the operation is exported by Domain.
\begin{axiom}
Integer::InputForm
Ring::InputForm
\end{axiom}

Waldek suggested the following way of converting a type
to InputForm.
\begin{spad}
)abbrev package GETTYNM GetTypeName
GetTypeName(T : Type) : with
   coerce: () -> InputForm
 == add
     coerce() == (devaluate(T)$Lisp) pretend InputForm
\end{spad}

\begin{axiom}
coerce()$GetTypeName(Integer)
coerce()$GetTypeName(SquareMatrix(3,PrimeField 7))
unparse(%)
\end{axiom}

PositiveInteger? and NonNegativeInteger? are subdomains of Integer.

Domain is a domain whose values are all domains. Categories are values of the domain SubDomain Domain. For example:

axiom
Integer
LatexWiki Image(1)
Type: Domain
axiom
Ring
LatexWiki Image(2)
Type: SubDomain? Domain

Unfortunately the original Axiom library did not include definitions of these domains.

axiom
[Integer,PrimeField(3)]
LISP output: (UNPRINTABLE UNPRINTABLE)
Type: List Domain

axiom
[Ring,Field]
LISP output: (UNPRINTABLE UNPRINTABLE)
Type: List SubDomain? Domain

However OpenAxiom? has implemented Domain and replaced SubDomain Domain with Category. Here we try to provide something similar for FriCAS?.

spad
)abbrev domain DOMAIN Domain
Domain():SetCategory with CoercibleTo(InputForm)
  == add
    coerce(x:%):OutputForm ==
      n:SExpression:=devaluate(x)$Lisp
      #n=1 => car(n) pretend OutputForm
      n pretend OutputForm
    x = y ==
      devaluate(x)$Lisp = devaluate(y)$Lisp
    coerce(x:%):InputForm ==
      devaluate(x)$Lisp
spad
   Compiling FriCAS source code from file 
      /var/zope2/var/LatexWiki/1943939720501734443-25px004.spad using 
      old system compiler.
   DOMAIN abbreviates domain Domain 
------------------------------------------------------------------------
   initializing NRLIB DOMAIN for Domain 
   compiling into NRLIB DOMAIN 
   compiling exported coerce : $ -> OutputForm
Time: 0.01 SEC.
compiling exported = : ($,$) -> Boolean Time: 0 SEC.
compiling exported coerce : $ -> InputForm DOMAIN;coerce;$If;3 is replaced by devaluate Time: 0.01 SEC.
(time taken in buildFunctor: 0)
;;; *** |Domain| REDEFINED
;;; *** |Domain| REDEFINED Time: 0 SEC.
Cumulative Statistics for Constructor Domain Time: 0.02 seconds
finalizing NRLIB DOMAIN Processing Domain for Browser database: --->-->Domain(): Missing Description ------------------------------------------------------------------------ Domain is now explicitly exposed in frame initial Domain will be automatically loaded when needed from /var/zope2/var/LatexWiki/DOMAIN.NRLIB/DOMAIN

spad
)abbrev domain SUBDOM SubDomain
SubDomain(D:Domain):SetCategory with CoercibleTo(InputForm)
  == add
    coerce(x:%):OutputForm ==
      n:SExpression:=devaluate(x)$Lisp
      #n=1 => car(n) pretend OutputForm
      n pretend OutputForm
    x = y ==
      devaluate(x)$Lisp = devaluate(y)$Lisp
    coerce(x:%):InputForm ==
      devaluate(x)$Lisp
spad
   Compiling FriCAS source code from file 
      /var/zope2/var/LatexWiki/7683481912116905837-25px005.spad using 
      old system compiler.
   SUBDOM abbreviates domain SubDomain 
------------------------------------------------------------------------
   initializing NRLIB SUBDOM for SubDomain 
   compiling into NRLIB SUBDOM 
   compiling exported coerce : $ -> OutputForm
Time: 0.01 SEC.
compiling exported = : ($,$) -> Boolean Time: 0.01 SEC.
compiling exported coerce : $ -> InputForm SUBDOM;coerce;$If;3 is replaced by devaluate Time: 0 SEC.
(time taken in buildFunctor: 0)
;;; *** |SubDomain| REDEFINED
;;; *** |SubDomain| REDEFINED Time: 0 SEC.
Cumulative Statistics for Constructor SubDomain Time: 0.02 seconds
finalizing NRLIB SUBDOM Processing SubDomain for Browser database: --->-->SubDomain(): Missing Description ------------------------------------------------------------------------ SubDomain is now explicitly exposed in frame initial SubDomain will be automatically loaded when needed from /var/zope2/var/LatexWiki/SUBDOM.NRLIB/SUBDOM

axiom
[Integer,PrimeField(3)]
LatexWiki Image(3)
Type: List Domain
axiom
%.1
LatexWiki Image(4)
Type: Domain

axiom
[Ring,Field,IntegerNumberSystem]
LatexWiki Image(5)
Type: List SubDomain? Domain

Although it is exported:

axiom
)sh Domain
Domain is a domain constructor Abbreviation for Domain is DOMAIN This constructor is exposed in this frame. ------------------------------- Operations -------------------------------- ?=? : (%,%) -> Boolean coerce : % -> InputForm coerce : % -> OutputForm hash : % -> SingleInteger latex : % -> String ?~=? : (%,%) -> Boolean

unfortunately the interpreter still does not seem to be able to call the coerce to InputForm function even though the operation is exported by Domain.

axiom
Integer::InputForm
Cannot convert from type Domain to InputForm for value Integer()
Ring::InputForm
Cannot convert from type SubDomain Domain to InputForm for value Ring()

Waldek suggested the following way of converting a type to InputForm?.

spad
)abbrev package GETTYNM GetTypeName
GetTypeName(T : Type) : with
   coerce: () -> InputForm
 == add
     coerce() == (devaluate(T)$Lisp) pretend InputForm
spad
   Compiling FriCAS source code from file 
      /var/zope2/var/LatexWiki/6678787279064774657-25px010.spad using 
      old system compiler.
   GETTYNM abbreviates package GetTypeName 
------------------------------------------------------------------------
   initializing NRLIB GETTYNM for GetTypeName 
   compiling into NRLIB GETTYNM 
   compiling exported coerce : () -> InputForm
Time: 0.01 SEC.
(time taken in buildFunctor: 0)
;;; *** |GetTypeName| REDEFINED
;;; *** |GetTypeName| REDEFINED Time: 0 SEC.
Warnings: [1] coerce: pretend(InputForm) -- should replace by @
Cumulative Statistics for Constructor GetTypeName Time: 0.01 seconds
finalizing NRLIB GETTYNM Processing GetTypeName for Browser database: --->-->GetTypeName((coerce ((InputForm)))): Not documented!!!! --->-->GetTypeName(constructor): Not documented!!!! --->-->GetTypeName(): Missing Description ------------------------------------------------------------------------ GetTypeName is now explicitly exposed in frame initial GetTypeName will be automatically loaded when needed from /var/zope2/var/LatexWiki/GETTYNM.NRLIB/GETTYNM

axiom
coerce()$GetTypeName(Integer)
LatexWiki Image(6)
Type: InputForm?
axiom
coerce()$GetTypeName(SquareMatrix(3,PrimeField 7))
LatexWiki Image(7)
Type: InputForm?
axiom
unparse(%)
LatexWiki Image(8)
Type: String