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

Using OpenAxiom

fricas
)version
Value = "Tuesday October 13, 2009 at 18:38:59 "

spad
)abbrev domain MORPH Morphism
T ==> SetCategory
Morphism(source:T, target:T): with
  domain:%->T
  codomain:%->T
  coerce:(source->target)  -> %
  coerce:%->(source->target)
  coerce:%->OutputForm
  elt:(%,source)->target
 == (source->target) add
  -- Rep == (source->target)
  Rep == SExpression
  domain(p:%):T == source
  codomain(p:%):T == target
  coerce(r:(source->target)):% == per(r pretend SExpression)
  coerce(p:%):(source->target) == (rep(p) pretend (source->target))
  coerce(p:%):OutputForm == p pretend OutputForm
  elt(f,x) == (rep(f) pretend (source->target))(x)
spad
   Compiling OpenAxiom source code from file 
      /var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/6008188987750019428-25px002.spad
      using Spad compiler.
   MORPH abbreviates domain Morphism 
   processing macro definition T$ ==> SetCategory 
------------------------------------------------------------------------ initializing NRLIB MORPH for Morphism compiling into NRLIB MORPH Adding $ modemaps Adding source modemaps Adding target modemaps Adding Rep modemaps compiling exported domain : % -> SetCategory Time: 0.01 SEC.
compiling exported codomain : % -> SetCategory Time: 0 SEC.
compiling exported coerce : source -> target -> % Adding SExpression modemaps MORPH;coerce;M$;3 is replaced by r Time: 0 SEC.
compiling exported coerce : % -> source -> target Adding SExpression modemaps MORPH;coerce;$M;4 is replaced by p Time: 0.01 SEC.
Adding OutputForm modemaps compiling exported coerce : % -> OutputForm MORPH;coerce;$Of;5 is replaced by p Time: 0 SEC.
compiling exported elt : (%,source) -> target Adding SExpression modemaps MORPH;elt;$sourcetarget;6 is replaced by SPADCALLxf Time: 0 SEC.
(time taken in buildFunctor: 0)
;;; *** |Morphism| REDEFINED
;;; *** |Morphism| REDEFINED Time: 0 SEC.
Cumulative Statistics for Constructor Morphism Time: 0.02 seconds
--------------non extending category---------------------- Morphism(#1,#2) of category CATEGORY(domain,domain: % -> SetCategory,codomain: % -> SetCategory,coerce: (#1 -> #2) -> %, coerce: % -> (#1 -> #2),coerce: % -> OutputForm,elt: (%,#1) -> #2) has no NIL finalizing NRLIB MORPH Processing Morphism for Browser database: --->-->Morphism((domain (T$ %))): Not documented!!!! --->-->Morphism((codomain (T$ %))): Not documented!!!! --->-->Morphism((coerce (% (Mapping target source)))): Not documented!!!! --->-->Morphism((coerce ((Mapping target source) %))): Not documented!!!! --->-->Morphism((coerce ((OutputForm) %))): Not documented!!!! --->-->Morphism((elt (target % source))): Not documented!!!! --->-->Morphism(constructor): Not documented!!!! --->-->Morphism: Missing Description
; compiling file "/var/aw/var/LatexWiki/MORPH.NRLIB/code.lsp" (written 14 JUL 2013 10:48:30 AM): ; compiling (/VERSIONCHECK 2) ; compiling (DEFUN |MORPH;domain;$Sc;1| ...) ; compiling (DEFUN |MORPH;codomain;$Sc;2| ...) ; compiling (PUT (QUOTE |MORPH;coerce;M$;3|) ...) ; compiling (DEFUN |MORPH;coerce;M$;3| ...) ; compiling (PUT (QUOTE |MORPH;coerce;$M;4|) ...) ; compiling (DEFUN |MORPH;coerce;$M;4| ...) ; compiling (PUT (QUOTE |MORPH;coerce;$Of;5|) ...) ; compiling (DEFUN |MORPH;coerce;$Of;5| ...) ; compiling (PUT (QUOTE |MORPH;elt;$sourcetarget;6|) ...) ; compiling (DEFUN |MORPH;elt;$sourcetarget;6| ...) ; compiling (DEFUN |Morphism| ...) ; compiling (DEFUN |Morphism;| ...) ; compiling (MAKEPROP (QUOTE |Morphism|) ...)
; /var/aw/var/LatexWiki/MORPH.NRLIB/code.fasl written ; compilation finished in 0:00:00.146 ------------------------------------------------------------------------ Morphism is now explicitly exposed in frame initial Morphism will be automatically loaded when needed from /var/aw/var/LatexWiki/MORPH.NRLIB/code.fasl

The naive representation of Rep == (source->target) gives the following error:

  Error: Caught fatal error [memory may be damaged]
  ...
  Error signalled by EVALHOOK.
  Backtrace: system:universal-error-handler > evalhook > lambda > lambda-closure > block > apply > APPLY

But using SExpression seems to work.

fricas
)show Morphism(Float,Integer)
Morphism(Float,Integer) is a domain constructor. Abbreviation for Morphism is MORPH This constructor is exposed in this frame. Issue )edit /var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/6008188987750019428-25px002.spad to see algebra source code for MORPH
------------------------------- Operations --------------------------------
codomain : % -> SetCategory coerce : % -> (Float -> Integer) coerce : % -> OutputForm coerce : (Float -> Integer) -> % domain : % -> SetCategory ?.? : (%,Float) -> Integer
f:Morphism(Float,Integer)
Type: Void
fricas
f:=(x:Float):Integer +->wholePart(x)

\label{eq1}; anonymousFunction ; 0 ; initial ; internal(1)
Type: Morphism(Float,Integer)
fricas
f(1.1)

\label{eq2}1(2)
fricas
(f::(Float->Integer))(1.1)

\label{eq3}1(3)
fricas
domain f

\label{eq4}\hbox{\axiomType{Float}\ }(4)
fricas
codomain f

\label{eq5}\hbox{\axiomType{Integer}\ }(5)
fricas
(f::(domain(f)->codomain(f)))(1.1)

\label{eq6}1(6)
fricas
g:Morphism(Integer,String):=(i:Integer):String +-> i::String

\label{eq7}; anonymousFunction ; 1 ; initial ; internal(7)
Type: Morphism(Integer,String)
fricas
g(1985)

\label{eq8}\mbox{\tt "1985"}(8)
Type: String

Next let's study how this sort of thing is accomplished in a similar domain.

spad
)abbrev domain HOM Hom
++ Based on Automorphism by: Manuel Bronstein
++ Description:
++       Hom(R,S) is the domain of homomorphisms - Mapping(S,R).
Hom(R:SetCategory,S:SetCategory): Join(SetCategory, Eltable(R, S)) with
      morphism: (R -> S) -> %
        ++ morphism(f) returns the non-invertible morphism given by f.
   == add
      -- Why doesn't the obvious representation just (R->S) work?
      Rep == SExpression
      morphism(f) == per(f pretend SExpression)
      elt(f, r)   == (rep(f) pretend (R->S))(r)
--Rep == List(R -> S) --morphism(f) == per([f #1]) --elt(f, r) == (rep(f)(1))(r)
--Rep := ((R, Integer) -> S) --morphism(f) == (#2; f(#1)) --elt(f, r) == (g := f pretend ((R, Integer) -> S); g(r, 1))
f = g == EQ(f, g)$Lisp coerce(f:%):OutputForm == message("theMap ...")
spad
   Compiling OpenAxiom source code from file 
      /var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/8077618115899383420-25px004.spad
      using Spad compiler.
   HOM abbreviates domain Hom 
------------------------------------------------------------------------
   initializing NRLIB HOM for Hom 
   compiling into NRLIB HOM 
   Adding $ modemaps
   Adding R modemaps
   Adding S modemaps
   Adding Rep modemaps
   compiling exported morphism : R -> S -> %
   Adding SExpression modemaps
      HOM;morphism;M$;1 is replaced by f 
Time: 0.01 SEC.
compiling exported elt : (%,R) -> S Adding SExpression modemaps HOM;elt;$RS;2 is replaced by SPADCALLrf Time: 0 SEC.
Adding Boolean modemaps compiling exported = : (%,%) -> Boolean HOM;=;2$B;3 is replaced by EQ Time: 0 SEC.
Adding OutputForm modemaps compiling exported coerce : % -> OutputForm Adding String modemaps Time: 0.01 SEC.
(time taken in buildFunctor: 0)
;;; *** |Hom| REDEFINED
;;; *** |Hom| REDEFINED Time: 0 SEC.
Cumulative Statistics for Constructor Hom Time: 0.02 seconds
finalizing NRLIB HOM Processing Hom for Browser database: -- morphism : (R -> S) -> % -- constructor ; compiling file "/var/aw/var/LatexWiki/HOM.NRLIB/code.lsp" (written 14 JUL 2013 10:48:30 AM): ; compiling (/VERSIONCHECK 2) ; compiling (PUT (QUOTE |HOM;morphism;M$;1|) ...) ; compiling (DEFUN |HOM;morphism;M$;1| ...) ; compiling (PUT (QUOTE |HOM;elt;$RS;2|) ...) ; compiling (DEFUN |HOM;elt;$RS;2| ...) ; compiling (PUT (QUOTE |HOM;=;2$B;3|) ...) ; compiling (DEFUN |HOM;=;2$B;3| ...) ; compiling (DEFUN |HOM;coerce;$Of;4| ...) ; compiling (DEFUN |Hom| ...) ; compiling (DEFUN |Hom;| ...) ; compiling (MAKEPROP (QUOTE |Hom|) ...)
; /var/aw/var/LatexWiki/HOM.NRLIB/code.fasl written ; compilation finished in 0:00:00.019 ------------------------------------------------------------------------ Hom is now explicitly exposed in frame initial Hom will be automatically loaded when needed from /var/aw/var/LatexWiki/HOM.NRLIB/code.fasl

fricas
p:=morphism((x:Integer):Float +-> x+1.0)$Hom(Integer,Float)

\label{eq9}\mbox{\rm theMap...}(9)
Type: Hom(Integer,Float)
fricas
p(2)

\label{eq10}3.0(10)
Type: Float
fricas
p(-1)

\label{eq11}0.0(11)
Type: Float




  Subject:   Be Bold !!
  ( 13 subscribers )  
Please rate this page: