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

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

)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->%
_-:(%,%)->%
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('+::OutputForm, [ _
if is2(s) then _
infix('+::OutputForm, [ _
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
   Compiling FriCAS source code from file
using old system compiler.
FRING abbreviates domain FreeRing
------------------------------------------------------------------------
compiling into NRLIB FRING
processing macro definition RepSum ==> FreeSum(FreeAbelianGroup A,FreeAbelianGroup $) processing macro definition RepPrd ==> FreeProduct(FreeMonoid A,FreeMonoid$)
processing macro definition Rep ==> Union(sum: FreeSum(FreeAbelianGroup A,FreeAbelianGroup $),prd: FreeProduct(FreeMonoid A,FreeMonoid$))
compiling local rep : $-> Union(sum: FreeSum(FreeAbelianGroup A,FreeAbelianGroup$),prd: FreeProduct(FreeMonoid A,FreeMonoid $)) FRING;rep is replaced by x Time: 0.01 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.04 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 SEC. compiling exported * : ($,$) ->$
Time: 0 SEC.
compiling exported - : $->$
Time: 0.01 SEC.
compiling exported - : ($,$) -> $Time: 0 SEC. compiling exported * : (Integer,$) -> $Time: 0 SEC. compiling exported coerce : Integer ->$
Time: 0.01 SEC.
****** Domain: A already in scope
augmenting A: (Comparable)
(time taken in buildFunctor:  0)
;;;     ***       |FreeRing| REDEFINED
;;;     ***       |FreeRing| REDEFINED
Time: 0 SEC.
Semantic Errors:
 coerce:  t has two modes:
 coerce:  s has two modes:
Warnings:
 per: cannot pretend x of mode (Union (: sum (FreeSum (FreeAbelianGroup A) (FreeAbelianGroup $))) (: prd (FreeProduct (FreeMonoid A) (FreeMonoid$)))) to mode $ coerce:$$has no value  coerce: prd has no value  +: sum has no value  *: prd has no value  -: sum has no value Cumulative Statistics for Constructor FreeRing Time: 0.08 seconds finalizing NRLIB FRING Processing FreeRing for Browser database: --------constructor--------- --->-->FreeRing((coerce (% A))): Not documented!!!! --->-->FreeRing((- (% % %))): Not documented!!!! ; compiling file "/var/aw/var/LatexWiki/FRING.NRLIB/FRING.lsp" (written 31 JUL 2013 03:43:05 PM): ; /var/aw/var/LatexWiki/FRING.NRLIB/FRING.fasl written ; compilation finished in 0:00:00.078 ------------------------------------------------------------------------ FreeRing is now explicitly exposed in frame initial FreeRing will be automatically loaded when needed from /var/aw/var/LatexWiki/FRING.NRLIB/FRING fricas f:=FreeRing(Symbol) (1) Type: Type fricas (a,b,c):f:=('a,'b,'c) (2) Type: FreeRing(Symbol) fricas a*b+b*a (3) Type: FreeRing(Symbol) fricas ab:=a+b (4) Type: FreeRing(Symbol) fricas ac:=a*c (5) Type: FreeRing(Symbol) fricas ab*ac (6) Type: FreeRing(Symbol) fricas a^(-2)+b^2 fricas Compiling function G760 with type Integer -> Boolean There are 16 exposed and 19 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 (7)
Type: FreeRing(Symbol)
fricas
a+b-(a+b) (8)
Type: FreeRing(Symbol)
fricas
3*a+2*b+c (9)
Type: FreeRing(Symbol)

 Subject:   Be Bold !! ( 14 subscribers )