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

Edit detail for FreeRing revision 1 of 2

1 2
Editor: Bill Page
Time: 2009/09/23 01:16:48 GMT-7
Note: new

changed:
-
\begin{axiom}
)lib FPROD
)lib FSUM
\end{axiom}

\begin{spad}
)abbrev domain FRING FreeRing
++ Description:
++ One can construct the free algebra R<E> on any set A of generators.
++ Since rings may be regarded as Z-algebras, a free ring on A can be
++ defined as the free algebra Z<E>
++ Ref: http://en.wikipedia.org/wiki/Free_ring
FreeRing(A:SetCategory):Ring with
    if A has Comparable then Comparable
    coerce:A->%
    _-:(%,%)->%
  == add
    RepSum == FreeSum(FreeAbelianGroup A,FreeAbelianGroup %)
    RepPrd == FreeProduct(FreeMonoid A,FreeMonoid %)
    Rep == Union(sum:RepSum,prd:RepPrd)
    rep(x:%):Rep == x pretend Rep
    per(x:Rep):% == x pretend %
    coerce(x:%):OutputForm ==
      r:=rep(x)
      if x=0 or x=1 then return coerce(r)
      if r case sum then infix(_+, [ _
        if is2(s) then _
          infix(_+, [ _
           if t.exp=1 then coerce(t.gen) _
           else if t.gen=1 then coerce(t.exp)
           else coerce(t.exp)*coerce(t.gen) _
           for t in terms(retract(s)@FreeAbelianGroup(%)) ]) _
        else coerce(s)
        for s in terms(r.sum)])
      else blankSeparate [ _
        if is2(s) then _
          blankSeparate [ _
           if t.exp=1 then paren(coerce(t.gen)) _
           else paren(coerce(t.gen)^coerce(t.exp)) _
           for t in factors(retract(s)@FreeMonoid(%)) ] _
        else coerce(s)
        for s in factors(r.prd)]

    --coerce(x:A):% == per [in1(coerce x)$RepSum]
    coerce(x:A):% == per [in1(coerce x)$RepPrd]

    Zero():% == per [0$RepSum]
    One():% == per [1$RepPrd]
    (x:% = y:%):Boolean == (rep(x) = rep(y))$Rep
    (x1:% + x2:%):% ==
      if x1=0 then return x2
      if x2=0 then return x1
      r1:=rep(x1); r2:=rep(x2)
      if r1 case sum then s1:=r1.sum else s1:=in2(coerce x1)$RepSum
      if r2 case sum then s2:=r2.sum else s2:=in2(coerce x2)$RepSum
      per [s1+s2]
    (x1:% * x2:%):% ==
      if x1=0 then return 0
      if x2=0 then return 0
      if x1=1 then return x2
      if x2=1 then return x1
      r1:=rep(x1); r2:=rep(x2)
      if r1 case prd then p1:=r1.prd else p1:=in2(coerce x1)$RepPrd
      if r2 case prd then p2:=r2.prd else p2:=in2(coerce x2)$RepPrd
      per [p1*p2]
    _-(x:%):% ==
      if x=0 then return 0
      r:=rep(x)
      if r case sum then s:=r.sum else s:=in2(coerce x)$RepSum
      per [-s]
    (x:% - y:%):% == x + (-y)
    (n:Integer * x:%):% ==
      if x=0 then return 0
      if n>0 then return (n-1) * x + x
      if n<0 then return (n+1) * x - x
      return 0
    coerce(x:Integer):% == x*1      
\end{spad}

\begin{axiom}
f:=FreeRing(Symbol)
(a,b,c):f:=('a,'b,'c)
a*b+b*a
ab:=a+b
ac:=a*c
ab*ac
a^(-2)+b^2
a*b-b*a
a+b-(a+b)
3*a+2*b+c
\end{axiom}


axiom
)lib FPROD
FreeProduct is now explicitly exposed in frame initial FreeProduct will be automatically loaded when needed from /var/zope2/var/LatexWiki/FPROD.NRLIB/FPROD
axiom
)lib FSUM
FreeSum is now explicitly exposed in frame initial FreeSum will be automatically loaded when needed from /var/zope2/var/LatexWiki/FSUM.NRLIB/FSUM

spad
)abbrev domain FRING FreeRing
++ Description:
++ One can construct the free algebra R<E> on any set A of generators.
++ Since rings may be regarded as Z-algebras, a free ring on A can be
++ defined as the free algebra Z<E>
++ Ref: http://en.wikipedia.org/wiki/Free_ring
FreeRing(A:SetCategory):Ring with
    if A has Comparable then Comparable
    coerce:A->%
    _-:(%,%)->%
  == add
    RepSum == FreeSum(FreeAbelianGroup A,FreeAbelianGroup %)
    RepPrd == FreeProduct(FreeMonoid A,FreeMonoid %)
    Rep == Union(sum:RepSum,prd:RepPrd)
    rep(x:%):Rep == x pretend Rep
    per(x:Rep):% == x pretend %
    coerce(x:%):OutputForm ==
      r:=rep(x)
      if x=0 or x=1 then return coerce(r)
      if r case sum then infix(_+, [ _
        if is2(s) then _
          infix(_+, [ _
           if t.exp=1 then coerce(t.gen) _
           else if t.gen=1 then coerce(t.exp)
           else coerce(t.exp)*coerce(t.gen) _
           for t in terms(retract(s)@FreeAbelianGroup(%)) ]) _
        else coerce(s)
        for s in terms(r.sum)])
      else blankSeparate [ _
        if is2(s) then _
          blankSeparate [ _
           if t.exp=1 then paren(coerce(t.gen)) _
           else paren(coerce(t.gen)^coerce(t.exp)) _
           for t in factors(retract(s)@FreeMonoid(%)) ] _
        else coerce(s)
        for s in factors(r.prd)]
--coerce(x:A):% == per [in1(coerce x)$RepSum] coerce(x:A):% == per [in1(coerce x)$RepPrd]
Zero():% == per [0$RepSum] One():% == per [1$RepPrd] (x:% = y:%):Boolean == (rep(x) = rep(y))$Rep (x1:% + x2:%):% == if x1=0 then return x2 if x2=0 then return x1 r1:=rep(x1); r2:=rep(x2) if r1 case sum then s1:=r1.sum else s1:=in2(coerce x1)$RepSum if r2 case sum then s2:=r2.sum else s2:=in2(coerce x2)$RepSum per [s1+s2] (x1:% * x2:%):% == if x1=0 then return 0 if x2=0 then return 0 if x1=1 then return x2 if x2=1 then return x1 r1:=rep(x1); r2:=rep(x2) if r1 case prd then p1:=r1.prd else p1:=in2(coerce x1)$RepPrd if r2 case prd then p2:=r2.prd else p2:=in2(coerce x2)$RepPrd per [p1*p2] _-(x:%):% == if x=0 then return 0 r:=rep(x) if r case sum then s:=r.sum else s:=in2(coerce x)$RepSum per [-s] (x:% - y:%):% == x + (-y) (n:Integer * x:%):% == if x=0 then return 0 if n>0 then return (n-1) * x + x if n<0 then return (n+1) * x - x return 0 coerce(x:Integer):% == x*1
spad
   Compiling FriCAS source code from file 
      /var/zope2/var/LatexWiki/4793027643467466752-25px002.spad using 
      old system compiler.
   FRING abbreviates domain FreeRing 
------------------------------------------------------------------------
   initializing NRLIB FRING for FreeRing 
   compiling into NRLIB FRING 
   compiling local rep : $ -> Union(sum: FreeSum(FreeAbelianGroup A,FreeAbelianGroup $),prd: FreeProduct(FreeMonoid A,FreeMonoid $))
      FRING;rep is replaced by x 
Time: 0.09 SEC.
compiling local per : Union(sum: FreeSum(FreeAbelianGroup A,FreeAbelianGroup $),prd: FreeProduct(FreeMonoid A,FreeMonoid $)) -> $ FRING;per is replaced by x Time: 0 SEC.
compiling exported coerce : $ -> OutputForm Time: 0.12 SEC.
compiling exported coerce : A -> $ Time: 0.01 SEC.
compiling exported Zero : () -> $ Time: 0 SEC.
compiling exported One : () -> $ Time: 0 SEC.
compiling exported = : ($,$) -> Boolean Time: 0 SEC.
compiling exported + : ($,$) -> $ Time: 0.01 SEC.
compiling exported * : ($,$) -> $ Time: 0.01 SEC.
compiling exported - : $ -> $ Time: 0 SEC.
compiling exported - : ($,$) -> $ Time: 0 SEC.
compiling exported * : (Integer,$) -> $ Time: 0.01 SEC.
compiling exported coerce : Integer -> $ Time: 0 SEC.
****** Domain: A already in scope augmenting A: (Comparable) (time taken in buildFunctor: 0)
;;; *** |FreeRing| REDEFINED
;;; *** |FreeRing| REDEFINED Time: 0.02 SEC.
Semantic Errors: [1] coerce: t has two modes:
Warnings: [1] per: cannot pretend x of mode (Union (: sum (FreeSum (FreeAbelianGroup A) (FreeAbelianGroup $))) (: prd (FreeProduct (FreeMonoid A) (FreeMonoid $)))) to mode $ [2] coerce: prd has no value [3] +: sum has no value [4] *: prd has no value [5] -: sum has no value
Cumulative Statistics for Constructor FreeRing Time: 0.27 seconds
finalizing NRLIB FRING Processing FreeRing for Browser database: --->-->FreeRing((coerce (% A))): Not documented!!!! --->-->FreeRing((- (% % %))): Not documented!!!! --------constructor--------- ; compiling file "/var/zope2/var/LatexWiki/FRING.NRLIB/FRING.lsp" (written 05 APR 2011 06:24:48 AM):
; /var/zope2/var/LatexWiki/FRING.NRLIB/FRING.fasl written ; compilation finished in 0:00:00.473 ------------------------------------------------------------------------ FreeRing is now explicitly exposed in frame initial FreeRing will be automatically loaded when needed from /var/zope2/var/LatexWiki/FRING.NRLIB/FRING
>> System error: The bounding indices 163 and 162 are bad for a sequence of length 162. See also: The ANSI Standard, Glossary entry for "bounding index designator" The ANSI Standard, writeup for Issue SUBSEQ-OUT-OF-BOUNDS:IS-AN-ERROR

axiom
f:=FreeRing(Symbol)

\label{eq1}\hbox{\axiomType{FreeRing}\ } (\hbox{\axiomType{Symbol}\ })(1)
Type: Type
axiom
(a,b,c):f:=('a,'b,'c)

\label{eq2}c(2)
Type: FreeRing?(Symbol)
axiom
a*b+b*a

\label{eq3}{\left({b \  a}\right)}+{\left({a \  b}\right)}(3)
Type: FreeRing?(Symbol)
axiom
ab:=a+b

\label{eq4}{\left(b \right)}+{\left(a \right)}(4)
Type: FreeRing?(Symbol)
axiom
ac:=a*c

\label{eq5}a \  c(5)
Type: FreeRing?(Symbol)
axiom
ab*ac

\label{eq6}{\left({\left(b \right)}+{\left(a \right)}\right)}\ {a \  c}(6)
Type: FreeRing?(Symbol)
axiom
a^(-2)+b^2
axiom
Compiling function G785 with type Integer -> Boolean 
   There are 16 exposed and 17 unexposed library operations named ^ 
      having 2 argument(s) but none was determined to be applicable. 
      Use HyperDoc Browse, or issue
                                )display op ^
      to learn more about the available operations. Perhaps 
      package-calling the operation or using coercions on the arguments
      will allow you to apply the operation.
Cannot find a definition or applicable library operation named ^ with argument type(s) FreeRing(Symbol) Integer
Perhaps you should use "@" to indicate the required return type, or "$" to specify which version of the function you need. a*b-b*a

\label{eq7}-{\left({b \  a}\right)}+{\left({a \  b}\right)}(7)
Type: FreeRing?(Symbol)
axiom
a+b-(a+b)

\label{eq8}0(8)
Type: FreeRing?(Symbol)
axiom
3*a+2*b+c

\label{eq9}{\left(c \right)}+{2 \ {\left(b \right)}}+{3 \ {\left(a \right)}}(9)
Type: FreeRing?(Symbol)