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

Introduction

Bi-graded two-color linear operators (transformations) over a finite n-dimensional vector space, including products and duals on a field . Members of this domain are morphisms where and (dual), etc. Products, permutations and composition (grafting) of morphisms are implemented. Operators are represented internally as tensors.

Operator composition and products can be visualized by oriented directed graphs. The graphs have a top and a bottom and arrows are directed either downwards or upwards.

External vertices in this graph represent vectors, tensors and their duals. Internal nodes and arcs (edges) represent linear operators. Edges may be one of two different "colors" (labelled + and - in the code that follows) or marked with arrows directed either downwards (+) or upwards (-). Horizontal juxtaposition (i.e. a horizontal cross-section) represents tensor product. Vertical juxtaposition of edges of the same color represents operator composition.

See examples and documentation below

I would be glad if you to make brief comments in the form at the bottom of this web page. For more detailed but related comments click discussion on the top menu.

Regards, Bill Page.

Source Code

We try to start by defining the concept of a compact closed category.

Ref:

)abbrev domain ARITY Arity
Arity():  Exports == Implementation where
COLOR ==> OrderedVariableList ['_+,'_-]
LIST2 ==> ListFunctions2
NNI ==> NonNegativeInteger
RS ==> Record(gen:COLOR,exp:NNI)
Exports ==> Join(Monoid, RetractableTo COLOR) with
index: PositiveInteger -> %
dn: () -> %
++ default
up: () -> %
++ dual
0: %
++ use 0 for identity
"+": (%,%) -> %
++ composition
size: % -> NonNegativeInteger
len: % -> Integer
color: (%,NNI) -> %
overlap: (%,%) -> Record(lm:%, mm:%, rm:%)
Rep ==> FreeMonoid COLOR
rep(x:%):Rep == x pretend Rep
per(x:Rep):% == x pretend %
index(x:PositiveInteger):% == per(index(x)$COLOR ::Rep) up():% == index(2) dn():% == index(1) 0:% == per 1 (f:% + g:%):% == per(rep f * rep g) coerce(x:%):OutputForm == (rep(x)=1 => message "0";rep(x)::OutputForm) -- size of FreeMonoid is just number of factors -- len is total length len(f:%):Integer == reduce(_+,map(x+->x.exp,factors rep f)$LIST2(RS,NNI),0)$List(NNI) pretend Integer -- i'th element color(f:%,i:NNI):% == j:NNI:=0 for x in factors rep f repeat j:=j+x.exp if j>=i then return per coerce x.gen error "index error" spad  Compiling FriCAS source code from file /var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/7355925127427701597-25px001.spad using old system compiler. ARITY abbreviates domain Arity ------------------------------------------------------------------------ initializing NRLIB ARITY for Arity compiling into NRLIB ARITY processing macro definition Rep ==> FreeMonoid OrderedVariableList construct(QUOTE +,QUOTE -) compiling local rep :$ -> FreeMonoid OrderedVariableList construct(QUOTE +,QUOTE -)
ARITY;rep is replaced by x
Time: 0.01 SEC.
compiling local per : FreeMonoid OrderedVariableList construct(QUOTE +,QUOTE -) -> $ARITY;per is replaced by x Time: 0 SEC. compiling exported index : PositiveInteger ->$
Time: 0 SEC.
compiling exported up : () -> $Time: 0 SEC. compiling exported dn : () ->$
Time: 0 SEC.
compiling exported Zero : () -> $Time: 0 SEC. compiling exported + : ($,$) ->$
Time: 0 SEC.
compiling exported coerce : $-> OutputForm Time: 0 SEC. compiling exported len :$ -> Integer
Time: 0.02 SEC.
compiling exported color : ($,NonNegativeInteger) ->$
Time: 0 SEC.
(time taken in buildFunctor:  0)
;;;     ***       |Arity| REDEFINED
;;;     ***       |Arity| REDEFINED
Time: 0 SEC.
Warnings:
[1] len:  exp has no value
[2] len: pretend(Integer) -- should replace by @
[3] color:  exp has no value
[4] color:  gen has no value
Cumulative Statistics for Constructor Arity
Time: 0.03 seconds
--------------non extending category----------------------
.. Arity of cat
(|Join| (|Monoid|)
(|RetractableTo| (|OrderedVariableList| (|construct| '+ '-)))
(CATEGORY |domain| (SIGNATURE |index| ($(|PositiveInteger|))) (SIGNATURE |dn| ($)) (SIGNATURE |up| ($)) (SIGNATURE (|Zero|) ($) |constant|) (SIGNATURE + ( $)) (SIGNATURE |size| ((|NonNegativeInteger|)$))
(SIGNATURE |len| ((|Integer|) $)) (SIGNATURE |color| ($ $(|NonNegativeInteger|))) (SIGNATURE |overlap| ((|Record| (|:| |lm|$) (|:| |mm| $) (|:| |rm|$)) ))))   has no
(|RetractableTo| (|OrderedVariableList| (|construct| + -)))    finalizing NRLIB ARITY
Processing Arity for Browser database:
--->-->Arity(constructor): Not documented!!!!
--->-->Arity((index (% (PositiveInteger)))): Not documented!!!!
--------(dn (%))---------
--------(up (%))---------
--------((Zero) (%) constant)---------
--->-->Arity(((Zero) (%) constant)): Improper first word in comments: use
"use 0 for identity"
--------(+ (% % %))---------
--->-->Arity((size ((NonNegativeInteger) %))): Not documented!!!!
--->-->Arity((len ((Integer) %))): Not documented!!!!
--->-->Arity((color (% % (NonNegativeInteger)))): Not documented!!!!
--->-->Arity((overlap ((Record (: lm %) (: mm %) (: rm %)) % %))): Not documented!!!!
--->-->Arity(): Missing Description
; compiling file "/var/aw/var/LatexWiki/ARITY.NRLIB/ARITY.lsp" (written 25 APR 2017 08:54:34 PM):
; /var/aw/var/LatexWiki/ARITY.NRLIB/ARITY.fasl written
; compilation finished in 0:00:00.029
------------------------------------------------------------------------
Arity is now explicitly exposed in frame initial
Arity will be automatically loaded when needed from
/var/aw/var/LatexWiki/ARITY.NRLIB/ARITY

)abbrev category CMONAL ClosedMonoidal
ClosedMonoidal():Category == Ring with
dom: % -> Arity
++ domain
cod: % -> Arity
++ co-domain
_/: (%,%) -> %
++ vertical composition f/g
apply: (%,%) -> %
++ horizontal product f g = f*g
"^": (%,Arity) -> %
++ colored power
dagger: % -> %
++ reverse arrows:
++ cod f = dom dagger f
++ dom f = cod dagger f
   Compiling FriCAS source code from file
using old system compiler.
CMONAL abbreviates category ClosedMonoidal
------------------------------------------------------------------------
initializing NRLIB CMONAL for ClosedMonoidal
compiling into NRLIB CMONAL
;;;     ***       |ClosedMonoidal| REDEFINED
Time: 0 SEC.
finalizing NRLIB CMONAL
Processing ClosedMonoidal for Browser database:
--->-->ClosedMonoidal(constructor): Not documented!!!!
--------(dom ((Arity) %))---------
--------(cod ((Arity) %))---------
--------(/ (% % %))---------
--->-->ClosedMonoidal((/ (% % %))): Improper first word in comments: vertical
--------(apply (% % %))---------
--->-->ClosedMonoidal((apply (% % %))): Improper first word in comments: horizontal
--------(^ (% % (Arity)))---------
--------(dagger (% %))---------
--->-->ClosedMonoidal(): Missing Description
; compiling file "/var/aw/var/LatexWiki/CMONAL.NRLIB/CMONAL.lsp" (written 25 APR 2017 08:54:34 PM):
; /var/aw/var/LatexWiki/CMONAL.NRLIB/CMONAL.fasl written
; compilation finished in 0:00:00.003
------------------------------------------------------------------------
ClosedMonoidal is now explicitly exposed in frame initial
ClosedMonoidal will be automatically loaded when needed from
/var/aw/var/LatexWiki/CMONAL.NRLIB/CMONAL

The initial object in this category is the domain ClosedProp? (Products and Permutations). The ClosedProp? domain represents everything that is "constant" about all the domains in this category. It can be defined as an endofunctor with only the information available about the category itself.

)abbrev domain CPROP ClosedProp
ClosedProp(L:ClosedMonoidal): Exports == Implementation where
Exports ==> ClosedMonoidal with
coerce: L -> %
Rep ==> Record(domain:Arity, codomain:Arity)
rep(x:%):Rep == x pretend Rep
per(x:Rep):% == x pretend %
coerce(f:%):OutputForm == dom(f)::OutputForm / cod(f)::OutputForm
coerce(f:L):% == per [dom f, cod f]                    -- coerce(f:L):% == per f
dom(x:%):Arity == rep(x).domain                          -- dom(x:%):NNI == dom rep x
cod(x:%):Arity == rep(x).codomain                        -- cod(x:%):NNI == cod rep x
--0:% == per [1,1]                                       -- 0:% == per 0
1:% == per [1,1]                                       -- 1:% == per 1
-- evaluation
(f:% / g:%):% == per [dom f, cod g]                    -- (f:% / g:%):% == per (rep f / rep g)
-- product
apply(f:%,g:%):% == per [dom f * dom g, cod f * cod g] -- apply(f:%,g:%):% == per apply(rep f,rep g)
(f:% * g:%):% == per [dom f * dom g, cod f * cod g]    --(f:% * g:%):% == per (rep f * rep g)
-- sum
--(f:% + g:%):% == per [dom f, cod f]                    --(f:% + g:%):% == per (rep f + rep g)
dagger(f:%):% == per [cod f, dom f]
(f:% ^ p:Arity):% ==
r:% := 1
for i in 1..len(p) repeat
if color(p,i)=dn() then
r:=r*f
else
r:=r*dagger(f)
return r
   Compiling FriCAS source code from file
using old system compiler.
CPROP abbreviates domain ClosedProp
------------------------------------------------------------------------
initializing NRLIB CPROP for ClosedProp
compiling into NRLIB CPROP
processing macro definition Rep ==> Record(domain: Arity,codomain: Arity)
compiling local rep : $-> Record(domain: Arity,codomain: Arity) CPROP;rep is replaced by x Time: 0 SEC. compiling local per : Record(domain: Arity,codomain: Arity) ->$
CPROP;per is replaced by x
Time: 0 SEC.
compiling exported coerce : $-> OutputForm Time: 0 SEC. compiling exported coerce : L ->$
Time: 0 SEC.
compiling exported dom : $-> Arity Time: 0 SEC. compiling exported cod :$ -> Arity
Time: 0 SEC.
compiling exported One : () -> $Time: 0 SEC. compiling exported / : ($,$) ->$
Time: 0 SEC.
compiling exported apply : ($,$) -> $Time: 0 SEC. compiling exported * : ($,$) ->$
Time: 0.01 SEC.
compiling exported dagger : $->$
Time: 0 SEC.
compiling exported ^ : ($,Arity) ->$
Time: 0 SEC.
(time taken in buildFunctor:  0)
;;;     ***       |ClosedProp| REDEFINED
;;;     ***       |ClosedProp| REDEFINED
Time: 0 SEC.
Warnings:
[1] dom:  domain has no value
[2] cod:  codomain has no value
Cumulative Statistics for Constructor ClosedProp
Time: 0.01 seconds
finalizing NRLIB CPROP
Processing ClosedProp for Browser database:
--->-->ClosedProp(constructor): Not documented!!!!
--->-->ClosedProp((coerce (% L))): Not documented!!!!
--->-->ClosedProp(): Missing Description
; compiling file "/var/aw/var/LatexWiki/CPROP.NRLIB/CPROP.lsp" (written 25 APR 2017 08:54:34 PM):
; /var/aw/var/LatexWiki/CPROP.NRLIB/CPROP.fasl written
; compilation finished in 0:00:00.034
------------------------------------------------------------------------
ClosedProp is now explicitly exposed in frame initial
ClosedProp will be automatically loaded when needed from
/var/aw/var/LatexWiki/CPROP.NRLIB/CPROP

The ClosedLinearOperator domain is ClosedMonoidal? over FreeMonoid OrderedVariables? ['_+,'_-]?, i.e. strings of symbols. The objects of this domain are all tensor powers of a vector space of fixed dimension. The arrows are linear operators that map from one object (tensor powers of vector space and it's dual) to another such power.

• all members of this domain have the same dimension

Faster tensors

fricas
)lib CARTEN
CartesianTensor is now explicitly exposed in frame initial
CartesianTensor will be automatically loaded when needed from
/var/aw/var/LatexWiki/CARTEN.NRLIB/CARTEN

)abbrev domain CLOP ClosedLinearOperator
ClosedLinearOperator(gener:OrderedFinite,K:Field): Exports == Implementation where
NNI ==> NonNegativeInteger
Exports ==> Join(Ring, VectorSpace K, ClosedMonoidal, RetractableTo K) with
arity: % -> ClosedProp %
basisOut: () -> List %
basisIn: () -> List %
map: (K->K,%) -> %
if K has Evalable(K) then Evalable(K)
eval: % -> %
ravel: % -> List K
unravel: (ClosedProp %,List K) -> %
coerce:(x:List Integer) -> %
++ identity for composition and permutations of its products
coerce:(x:List None) -> %
++ [] = 1
elt: (%,%) -> %
elt: (%,Integer) -> %
elt: (%,Integer,Integer) -> %
elt: (%,Integer,Integer,Integer) -> %
_/: (Tuple %,Tuple %) -> %
_/: (Tuple %,%) -> %
_/: (%,Tuple %) -> %
++ yet another syntax for product
ev: NNI -> %
++ (2,0)-tensor for evaluation
co: NNI -> %
++ (0,2)-tensor for co-evaluation
LIST2 ==> ListFunctions2
dim:NNI := size()$gener T := CartesianTensor(1,dim,K) L := Record(domain:Arity, codomain:Arity, data:T) RR := Record(gen:L,exp:NNI) -- FreeMonoid provides unevaluated products Rep ==> FreeMonoid L rep(x:%):Rep == x pretend Rep per(x:Rep):% == x pretend % dimension():CardinalNumber == coerce dim -- Prop (arity) dom(f:%):Arity == reduce(_*,map(x+->(x.gen.domain)^(x.exp),factors rep f)$LIST2(RR,Arity),1)$List(Arity) cod(f:%):Arity == reduce(_*,map(x+->(x.gen.codomain)^(x.exp),factors rep f)$LIST2(RR,Arity),1)$List(Arity) dagger(f:%):% == r:=1 for f1 in factors rep f repeat p:List Integer := concat [ _ [len(f1.gen.domain)+i for i in 1..len(f1.gen.codomain)], _ [i for i in 1..len(f1.gen.domain)]] r:= per(coerce [f1.gen.codomain, f1.gen.domain, reindex(f1.gen.data,p) ])^f1.exp * r return r prod(f:L,g:L):L == r:T := product(f.data,g.data) -- dom(f) + cod(f) + dom(g) + cod(g) p:List Integer := concat _ [[i for i in 1..len(f.domain)], _ [len(f.domain)+len(f.codomain)+i for i in 1..len(g.domain)], _ [len(f.domain)+i for i in 1..len(f.codomain)], _ [len(f.domain)+len(g.domain)+len(f.codomain)+i for i in 1..len(g.codomain)]] -- dom(f) + dom(g) + cod(f) + cod(g) --output("prod p = ",p::OutputForm)$OutputPackage
[(f.domain)*(g.domain),(f.codomain)*(g.codomain),reindex(r,p)]
dats(fs:List RR):L ==
r:L := [1,1,1$T] -- scalar 1 as tensor for y in fs repeat t:L:=y.gen for n in 1..y.exp repeat r:=prod(r,t) return r dat(f:Rep):L == dats factors f arity(f:%):ClosedProp % == f::ClosedProp % eval(f:%):% == per coerce dat(rep f) retractIfCan(f:%):Union(K,"failed") == dom(f)=1 and cod(f)=1 => retract(dat(rep f).data)$T
return "failed"
retract(f:%):K ==
dom(f)=1 and cod(f)=1 => retract(dat(rep f).data)$T error "failed" -- basis basisOut():List % == [per coerce [1,dn(),entries(row(1,i)$SquareMatrix(dim,K))::T] for i in 1..dim]
basisIn():List % == [per coerce [dn(),1,entries(row(1,i)$SquareMatrix(dim,K))::T] for i in 1..dim] ev(n:NNI):% == reduce(_+,[ dx^n * dx^n for dx in basisIn()])$List(%)
co(n:NNI):% == reduce(_+,[ Dx^n * Dx^n for Dx in basisOut()])$List(%) -- manipulation map(f:K->K, g:%):% == per coerce [dom g,cod g,unravel(map(f,ravel dat(rep g).data))$T]
if K has Evalable(K) then
eval(g:%,f:List Equation K):% == map((x:K):K+->eval(x,f),g)
ravel(g:%):List K == ravel dat(rep g).data
unravel(p:ClosedProp %,r:List K):% ==
dim^(len(dom(p)*cod(p)) pretend NNI) ~= #r => error "failed"
per coerce [dom(p),cod(p),unravel(r)$T] -- sum (f:% + g:%):% == dat(rep f).data=0 => g dat(rep g).data=0 => f dom(f) ~= dom(g) or cod(f) ~= cod(g) => error "arity" per coerce [dom f,cod f,dat(rep f).data+dat(rep g).data] (f:% - g:%):% == dat(rep f).data=0 => g dat(rep g).data=0 => f dom(f) ~= dom(f) or cod(g) ~= cod(g) => error "arity" per coerce [dom f, cod f,dat(rep f).data-dat(rep g).data] _-(f:%):% == per coerce [dom f, cod f,-dat(rep f).data] (x:% = y:%):Boolean == if rep x = rep y then true else rep eval x = rep eval y -- identity for sum (trivial zero map) 0 == per coerce [1,1,0] zero?(f:%):Boolean == dat(rep f).data = 0 * dat(rep f).data -- identity for product 1:% == per 1 one?(f:%):Boolean == one? rep f -- identity for composition I := per coerce [dn(),dn(),kroneckerDelta()$T]
-- permutations and identities
coerce(p:List Integer):% ==
r:=I^#p
--#p = 1 and p.1 = 1 => return r
p3:List Integer:=concat [ _
[i for i in 1..#p], _
[#p+abs(i) for i in p]]
d:Arity:=dn()^(#p)
c:Arity := reduce(_*,map((x:Integer):Arity+->(x>0=>dn();up()),p)$LIST2(Integer,Arity))$List(Arity)
r:=per coerce [d, c, reindex(dat(rep r).data,p3)]
return r
coerce(p:List None):% == per coerce [1,1,1]
-- twist
X := [2,1]::List Integer::%
-- product
elt(f:%,g:%):% == f * g
elt(f:%,g:Integer):% == f * [g @ Integer]::List Integer::%
elt(f:%,g1:Integer,g2:Integer):% == f * [g1 @ Integer,g2 @ Integer]::List Integer::%
elt(f:%,g1:Integer,g2:Integer,g3:Integer):% ==
f * [g1 @ Integer,g2 @ Integer,g3 @ Integer]::List Integer::%
apply(f:%,g:%):% == f * g
-- just free monoid product
(f:% * g:%):% ==
-- evaluate scalars
if f = 1 then return g
if g = 1 then return f
if dom(f)=1 and cod(f)=1 then
if dom(g)=1 and cod(g)=1 then
per coerce [1,1,coerce(retract(eval f)@K * retract(eval g)@K)]
else
per (rep(eval f) * rep g)
else
if dom(g)=1 and cod(g)=1 then
per (rep f * rep(eval g))
else
per (rep f * rep g)
coerce(x:K):% == 1*x
-- tensor powers
(f:% ^ p:Arity):% ==
r:% := 1
for i in 1..len(p) repeat
if color(p,i)=dn() then
r:=r*f
else
r:=r*dagger(f)
return r
-- returns arity of leading identities
xx := x
s:Arity:=1
repeat
r:=overlap(rep(I),xx)
--output("lead r = ", r::OutputForm)$OutputPackage if r.lm=1 and r.mm=rep(I) then s := s * dn() xx:= r.lm else r:=overlap(rep(dagger I),xx) if r.lm=1 and r.mm=rep(I) then s := s * up() xx:= r.lm else break return s -- returns arity of trailing identities trailI(x:Rep):Arity == xx := x s:Arity:=1 repeat r:=overlap(xx,rep(I)) --output("trail r = ", r::OutputForm)$OutputPackage
if r.rm=1 and r.mm=rep(I) then
s := dn() * s
xx:= r.rm
else
r:=overlap(xx,rep(dagger I))
if r.rm=1 and r.mm=rep(I) then
s := up() * s
xx:= r.rm
else
break
return s
-- tensor composition:
compose(lnf:Integer,f:Rep,lfn:Integer, lng:Integer,g:Rep,lgn:Integer):T ==
--output("lnf, lfn, lng, lgn = ", [lnf,lfn,lng,lgn]::List Integer::OutputForm)$OutputPackage ldf := len dom(per f) lcf := len cod(per f) ldg := len dom(per g) lcg := len cod(per g) --output("ldf, lcf, ldg, lcg = ", [ldf,lcf,ldg,lcg]::List Integer::OutputForm)$OutputPackage
--output("f, g = ", [f,g]::List Rep::OutputForm)$OutputPackage -- check for permutations (for now just twists) if lcf-lng-lgn=2 then if f=rep(X) then if g=rep(X) then -- compose permutations --output("f/g = I*I", 1::OutputForm)$OutputPackage
return dat(rep(I*I)).data
else -- twist input
p:List Integer := concat [ _
[i for i in 1..lnf], _
[lnf+2,lnf+1], _
[lnf+2+i for i in 1..lfn], _
[lnf+2+lfn+i for i in 1..lcg] ]
--print(p::OutputForm)$OutputForm return reindex(dat(g).data,p) else if g=rep(X) then -- twist output p:List Integer := concat [ _ [i for i in 1..ldf], _ [ldf+i for i in 1..lng], _ [ldf+lng+2,ldf+lng+1], _ [ldf+lng+2+i for i in 1..lgn] ] --print(p::OutputForm)$OutputForm
return reindex(dat(f).data,p)
r:T := contract(lcf-lng-lgn, dat(f).data,ldf+lng+1, dat(g).data,lnf+1)
p:List Integer:=concat [ _
[ldf+lgn+i for i in 1..lnf], _
[i for i in 1..ldf], _
[ldf+lnf+lng+i for i in 1..lfn], _
[ldf+i for i in 1..lng], _
[ldf+lnf+lng+lfn+lgn+i for i in 1..lcg], _
[ldf+lng+i for i in 1..lgn] ]
--print(p::OutputForm)$OutputForm return reindex(r,p) parallelize(f:Rep,g:Rep):Record(f1:Rep,g1:Rep,f2:Rep,g2:Rep) == -- parallelize composition f/g = (f1/g1)*(f2/g2) r:Record(f1:Rep,g1:Rep,f2:Rep,g2:Rep):=[1,1,1,1] if cod(per f)~=1 then i:Integer:=1 j:Integer:=1 n:NNI:=1 m:NNI:=1 r.f1 := nthFactor(f,1)::Rep r.g1 := nthFactor(g,1)::Rep --print(r::OutputForm)$OutputForm
while cod(per r.f1) ~= dom(per r.g1) repeat
if len(cod per r.f1) < len(dom per r.g1) then
if n < nthExpon(f,i) then
n:=n+1
else
n:=1
i:=i+1
r.f1 := r.f1 * nthFactor(f,i)::Rep
else if len(cod per r.f1) > len(dom per r.g1) then
if m < nthExpon(g,j) then
m:=m+1
else
n:=1
j:=j+1
r.g1 := r.g1 * nthFactor(g,j)::Rep
--print([cod(per r.f1)::OutputForm,dom(per r.g1)::OutputForm]::List OutputForm::OutputForm)$OutputForm r.f2 := overlap(r.f1, f).rm r.g2 := overlap(r.g1, g).rm return r -- f/g : A^n -> A^p = f:A^n -> A^m / g:A^m -> A^p (ff:% / gg:%):% == -- scalars if dom(ff)=1 and cod(ff)=1 and dom(gg)=1 and cod(gg)=1 then return ff*gg fg:=overlap(cod ff,dom gg) if fg.rm~=1 or fg.lm~=1 then -- pass extra f inputs on the left -- pass extra g outputs on the right print(hconcat([message("arity warning: "), _ over(arity(ff)::OutputForm * arity(I^(fg.rm))::OutputForm, _ arity(I^(fg.lm))::OutputForm * arity(gg)::OutputForm) ]))$OutputForm
r:=parallelize(rep(ff*I^(fg.rm)),rep(I^(fg.lm)*gg))
-- remove leading and trailing identities
r.f1 := overlap(rep(I^nf),r.f1).rm
r.g1 := overlap(rep(I^ng),r.g1).rm
--output("nf,ng = ",[nf,ng]::List Arity::OutputForm)$OutputPackage fn := trailI r.f1 f := overlap(r.f1,rep(I^fn)).lm gn := trailI r.g1 g := overlap(r.g1,rep(I^gn)).lm --output("fn,gn = ",[fn,gn]::List Arity::OutputForm)$OutputPackage
-- parallel factors guarantees that these are just identities
if nf~=1 and nf=ng then
return I^nf*(per(r.f2)/per(r.g2))
if fn~=1 and gn~=1 then
return (per(f)/per(g))*I^fn
return per([nf*dom(per f)*fn, ng*cod(per g)*gn, _
compose(len nf,f,len fn, len ng,g,len gn)]::Rep) * _
(per(r.f2)/per(r.g2))
-- another notation for composition of products
(t:Tuple % / x:%):% == t / construct([x])$PrimitiveArray(%)::Tuple(%) (x:% / t:Tuple %):% == construct([x])$PrimitiveArray(%)::Tuple(%) / t
(f:Tuple % / g:Tuple %):% ==
fs:List % := [select(f,i) for i in 0..#f-1]
gs:List % := [select(g,i) for i in 0..#g-1]
fr:=reduce(elt@(%,%)->%,fs,1)
gr:=reduce(elt@(%,%)->%,gs,1)
fr / gr
(x:K * y:%):% == per coerce [dom y, cod y,x*dat(rep y).data]
(x:% * y:K):% == per coerce [dom x,cod x,dat(rep x).data*y]
(x:Integer * y:%):% == per coerce [dom y,cod y,x*dat(rep y).data]
-- display operators using basis
show(x:%):OutputForm ==
dom(x)=1 and cod(x)=1 => return (dat(rep x).data)::OutputForm
gens:List OutputForm:=[index(i::PositiveInteger)$gener::OutputForm for i in 1..dim] -- input basis inps:List OutputForm := list empty() dx:=dom(x) for i in 1..len(dx) repeat --empty? inps => inps:=gens inps:=concat [[(inps.k * (color(dx,i)=dn()=>gens.j;super(gens.j,message "*"))) _ for j in 1..dim] for k in 1..#inps] -- output basis outs:List OutputForm := list empty() cx:=cod(x) for i in 1..len(cx) repeat --empty? outs => outs:=gens outs:=concat [[(outs.k * (color(cx,i)=dn()=>gens.j;super(gens.j,message "*"))) _ for j in 1..dim] for k in 1..#outs] -- combine input (superscripts) and/or output(subscripts) to form basis symbols bases:List OutputForm if #inps > 0 and #outs > 0 then bases:=concat([[ scripts(message("|"),[i,j]) for i in outs] for j in inps]) else if #inps > 0 then bases:=[super(message("|"),i) for i in inps] else if #outs > 0 then bases:=[sub(message("|"),j) for j in outs] else bases:List OutputForm:= [] -- merge bases with data to form term list terms:=[(k=1 => base;k::OutputForm*base) for base in bases for k in ravel(x) | k~=0] empty? terms => return 0::OutputForm -- combine the terms return reduce(_+,terms) coerce(x:%):OutputForm == r:OutputForm := empty() for y in factors(rep x) repeat if y.exp = 1 then if size rep x = 1 then r := show per coerce y.gen else r:=r*paren(list show per coerce y.gen) else r:=r*paren(list show per coerce y.gen)^(y.exp::OutputForm) return r spad  Compiling FriCAS source code from file /var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/5869708054946761164-25px005.spad using old system compiler. CLOP abbreviates domain ClosedLinearOperator ------------------------------------------------------------------------ initializing NRLIB CLOP for ClosedLinearOperator compiling into NRLIB CLOP processing macro definition LIST2 ==> ListFunctions2 processing macro definition Rep ==> FreeMonoid L compiling local rep :$ -> FreeMonoid L
CLOP;rep is replaced by x
Time: 0.01 SEC.
compiling local per : FreeMonoid L -> $CLOP;per is replaced by x Time: 0 SEC. compiling exported dimension : () -> CardinalNumber Time: 0 SEC. compiling exported dom :$ -> Arity
Time: 0 SEC.
compiling exported cod : $-> Arity Time: 0.01 SEC. compiling exported dagger :$ -> $Time: 0.34 SEC. compiling local prod : (L,L) -> L Time: 0.02 SEC. compiling local dats : List RR -> L Time: 0 SEC. compiling local dat : FreeMonoid L -> L Time: 0 SEC. compiling exported arity :$ -> ClosedProp $Time: 0.01 SEC. compiling exported eval :$ -> $Time: 0 SEC. compiling exported retractIfCan :$ -> Union(K,failed)
Time: 0 SEC.
compiling exported retract : $-> K Time: 0.01 SEC. compiling exported basisOut : () -> List$
Time: 0.01 SEC.
compiling exported basisIn : () -> List $Time: 0.01 SEC. compiling exported ev : NonNegativeInteger ->$
Time: 0.01 SEC.
compiling exported co : NonNegativeInteger -> $Time: 0.01 SEC. compiling exported map : (K -> K,$) -> $Time: 0 SEC. ****** Domain: K already in scope augmenting K: (Evalable K) compiling exported eval : ($,List Equation K) -> $Time: 0 SEC. compiling exported ravel :$ -> List K
Time: 0 SEC.
compiling exported unravel : (ClosedProp $,List K) ->$
Time: 0.08 SEC.
compiling exported + : ($,$) -> $Time: 0.01 SEC. compiling exported - : ($,$) ->$
Time: 0.01 SEC.
compiling exported - : $->$
Time: 0 SEC.
compiling exported = : ($,$) -> Boolean
Time: 0.01 SEC.
compiling exported Zero : () -> $Time: 0 SEC. compiling exported zero? :$ -> Boolean
Time: 0 SEC.
compiling exported One : () -> $Time: 0 SEC. compiling exported one? :$ -> Boolean
Time: 0 SEC.
compiling exported coerce : List Integer -> $Time: 0.01 SEC. compiling exported coerce : List None ->$
Time: 0.01 SEC.
compiling exported elt : ($,$) -> $Time: 0 SEC. compiling exported elt : ($,Integer) -> $Time: 0 SEC. compiling exported elt : ($,Integer,Integer) -> $Time: 0 SEC. compiling exported elt : ($,Integer,Integer,Integer) -> $Time: 0 SEC. compiling exported apply : ($,$) ->$
Time: 0 SEC.
compiling exported * : ($,$) -> $Time: 0.05 SEC. compiling exported coerce : K ->$
Time: 0.01 SEC.
compiling exported ^ : ($,Arity) ->$
Time: 0 SEC.
compiling local leadI : FreeMonoid L -> Arity
Time: 0.02 SEC.
compiling local trailI : FreeMonoid L -> Arity
Time: 0.02 SEC.
compiling local compose : (Integer,FreeMonoid L,Integer,Integer,FreeMonoid L,Integer) -> T$Time: 0.15 SEC. compiling local parallelize : (FreeMonoid L,FreeMonoid L) -> Record(f1: FreeMonoid L,g1: FreeMonoid L,f2: FreeMonoid L,g2: FreeMonoid L) Time: 0.02 SEC. compiling exported / : ($,$) ->$
Time: 1.18 SEC.
compiling exported / : (Tuple $,$) -> $Time: 0 SEC. compiling exported / : ($,Tuple $) ->$
Time: 0.01 SEC.
compiling exported / : (Tuple $,Tuple$) -> $Time: 0.01 SEC. compiling exported * : (K,$) -> $Time: 0 SEC. compiling exported * : ($,K) -> $Time: 0 SEC. compiling exported * : (Integer,$) -> $Time: 0 SEC. compiling local show :$ -> OutputForm
Time: 0.04 SEC.
compiling exported coerce : $-> OutputForm Time: 0.03 SEC. ****** Domain: K already in scope augmenting K: (Evalable K) (time taken in buildFunctor: 10) ;;; *** |ClosedLinearOperator| REDEFINED ;;; *** |ClosedLinearOperator| REDEFINED Time: 0.01 SEC. Warnings: [1] dom: gen has no value [2] dom: exp has no value [3] cod: gen has no value [4] cod: exp has no value [5] dagger: gen has no value [6] dagger: codomain has no value [7] dagger: exp has no value [8] prod: data has no value [9] prod: domain has no value [10] prod: codomain has no value [11] dats: gen has no value [12] dats: exp has no value [13] retractIfCan: data has no value [14] retract: data has no value [15] map: data has no value [16] ravel: data has no value [17] +: data has no value [18] -: data has no value [19] zero?: data has no value [20] coerce: data has no value [21] leadI: lm has no value [22] leadI: mm has no value [23] trailI: rm has no value [24] trailI: mm has no value [25] compose: data has no value [26] parallelize: f1 has no value [27] parallelize: g1 has no value [28] parallelize: i has no value [29] parallelize: j has no value [30] parallelize: f2 has no value [31] parallelize: g2 has no value [32] /: rm has no value [33] /: lm has no value [34] /: f1 has no value [35] /: g1 has no value [36] /: f2 has no value [37] /: g2 has no value [38] *: data has no value [39] show: data has no value [40] coerce: exp has no value [41] coerce: gen has no value Cumulative Statistics for Constructor ClosedLinearOperator Time: 2.12 seconds finalizing NRLIB CLOP Processing ClosedLinearOperator for Browser database: --->-->ClosedLinearOperator(constructor): Not documented!!!! --->-->ClosedLinearOperator((arity ((ClosedProp %) %))): Not documented!!!! --->-->ClosedLinearOperator((basisOut ((List %)))): Not documented!!!! --->-->ClosedLinearOperator((basisIn ((List %)))): Not documented!!!! --->-->ClosedLinearOperator((map (% (Mapping K K) %))): Not documented!!!! --->-->ClosedLinearOperator((eval (% %))): Not documented!!!! --->-->ClosedLinearOperator((ravel ((List K) %))): Not documented!!!! --->-->ClosedLinearOperator((unravel (% (ClosedProp %) (List K)))): Not documented!!!! --------(coerce (% (List (Integer))))--------- --->-->ClosedLinearOperator((coerce (% (List (Integer))))): Improper first word in comments: identity "identity for composition and permutations of its products" --------(coerce (% (List (None))))--------- --->-->ClosedLinearOperator((coerce (% (List (None))))): Improper first word in comments: [] "[] = 1" --->-->ClosedLinearOperator((elt (% % %))): Not documented!!!! --->-->ClosedLinearOperator((elt (% % (Integer)))): Not documented!!!! --->-->ClosedLinearOperator((elt (% % (Integer) (Integer)))): Not documented!!!! --->-->ClosedLinearOperator((elt (% % (Integer) (Integer) (Integer)))): Not documented!!!! --->-->ClosedLinearOperator((/ (% (Tuple %) (Tuple %)))): Not documented!!!! --->-->ClosedLinearOperator((/ (% (Tuple %) %))): Not documented!!!! --------(/ (% % (Tuple %)))--------- --->-->ClosedLinearOperator((/ (% % (Tuple %)))): Improper first word in comments: yet "yet another syntax for product" --------(ev (% (NonNegativeInteger)))--------- --->-->ClosedLinearOperator((ev (% (NonNegativeInteger)))): Improper first word in comments: "(2,{}0)-tensor for evaluation" --------(co (% (NonNegativeInteger)))--------- --->-->ClosedLinearOperator((co (% (NonNegativeInteger)))): Improper first word in comments: "(0,{}2)-tensor for co-evaluation" --->-->ClosedLinearOperator(): Missing Description ; compiling file "/var/aw/var/LatexWiki/CLOP.NRLIB/CLOP.lsp" (written 25 APR 2017 08:54:36 PM): ; /var/aw/var/LatexWiki/CLOP.NRLIB/CLOP.fasl written ; compilation finished in 0:00:00.483 ------------------------------------------------------------------------ ClosedLinearOperator is now explicitly exposed in frame initial ClosedLinearOperator will be automatically loaded when needed from /var/aw/var/LatexWiki/CLOP.NRLIB/CLOP Getting Started Consult the source code above for more details. Convenient Notation fricas -- summation macro Σ(f,i,b) == reduce(+,[f*b.i for i in 1..#b]) Type: Void fricas -- list comprehension macro Ξ(f,i)==[f for i in 1..retract(dimension()$L)]
Type: Void

Example

fricas
Q := EXPR INT
 (1)
Type: Type
fricas
L := CLOP(OVAR ['x,'y],Q)
 (2)
Type: Type
fricas
)show L
ClosedLinearOperator(OrderedVariableList([x,y]),Expression(Integer)) is a domain constructor.
Abbreviation for ClosedLinearOperator is CLOP
This constructor is exposed in this frame.
45 Names for 66 Operations in this Domain.
------------------------------- Operations --------------------------------
?*? : (Integer,%) -> %                ?*? : (PositiveInteger,%) -> %
?*? : (%,%) -> %                      ?+? : (%,%) -> %
?-? : (%,%) -> %                      -? : % -> %
?/? : (Tuple(%),Tuple(%)) -> %        ?/? : (Tuple(%),%) -> %
?/? : (%,Tuple(%)) -> %               ?/? : (%,%) -> %
?=? : (%,%) -> Boolean                1 : () -> %
0 : () -> %                           ?^? : (%,Arity) -> %
?^? : (%,PositiveInteger) -> %        annihilate? : (%,%) -> Boolean
antiCommutator : (%,%) -> %           apply : (%,%) -> %
arity : % -> ClosedProp(%)            associator : (%,%,%) -> %
basisIn : () -> List(%)               basisOut : () -> List(%)
co : NonNegativeInteger -> %          cod : % -> Arity
coerce : % -> OutputForm              coerce : Expression(Integer) -> %
coerce : Integer -> %                 coerce : List(Integer) -> %
coerce : List(None) -> %              commutator : (%,%) -> %
dagger : % -> %                       dimension : () -> CardinalNumber
dom : % -> Arity                      elt : (%,Integer,Integer) -> %
?.? : (%,Integer) -> %                ?.? : (%,%) -> %
ev : NonNegativeInteger -> %          eval : % -> %
hash : % -> SingleInteger             latex : % -> String
one? : % -> Boolean                   opposite? : (%,%) -> Boolean
recip : % -> Union(%,"failed")        sample : () -> %
zero? : % -> Boolean                  ?~=? : (%,%) -> Boolean
?*? : (Expression(Integer),%) -> %
?*? : (NonNegativeInteger,%) -> %
?*? : (%,Expression(Integer)) -> %
?/? : (%,Expression(Integer)) -> %
?^? : (%,NonNegativeInteger) -> %
characteristic : () -> NonNegativeInteger
elt : (%,Integer,Integer,Integer) -> %
hashUpdate! : (HashState,%) -> HashState
leftPower : (%,NonNegativeInteger) -> %
leftPower : (%,PositiveInteger) -> %
leftRecip : % -> Union(%,"failed")
map : ((Expression(Integer) -> Expression(Integer)),%) -> %
ravel : % -> List(Expression(Integer))
retract : % -> Expression(Integer)
retractIfCan : % -> Union(Expression(Integer),"failed")
rightPower : (%,NonNegativeInteger) -> %
rightPower : (%,PositiveInteger) -> %
rightRecip : % -> Union(%,"failed")
subtractIfCan : (%,%) -> Union(%,"failed")
unravel : (ClosedProp(%),List(Expression(Integer))) -> %

Basis

fricas
dim:Integer:=retract dimension()$L  (3) Type: Integer fricas Dx:=basisOut()$L
 (4)
Type: List(ClosedLinearOperator(OrderedVariableList([x,y]),Expression(Integer)))
fricas
dx:=basisIn()\$L
 (5)
Type: List(ClosedLinearOperator(OrderedVariableList([x,y]),Expression(Integer)))
fricas
matrix Ξ(Ξ( eval(dx.i * Dx.j), i),j)
 (6)
Type: Matrix(ClosedLinearOperator(OrderedVariableList([x,y]),Expression(Integer)))
fricas
matrix Ξ(Ξ( Dx.i / dx.j, i),j)
 (7)
Type: Matrix(ClosedLinearOperator(OrderedVariableList([x,y]),Expression(Integer)))

(1,1)-tensor

fricas
A:L := Σ( Σ( script(a,[[j],[i]]), i,Dx), j,dx)
 (8)
Type: ClosedLinearOperator(OrderedVariableList([x,y]),Expression(Integer))
fricas
a:=arity(A)
 (9)
Type: ClosedProp?(ClosedLinearOperator(OrderedVariableList([x,y]),Expression(Integer)))
fricas
p:=dom(A)
 (10)
Type: Arity

scalar

fricas
s:= 3::L
 (11)
Type: ClosedLinearOperator(OrderedVariableList([x,y]),Expression(Integer))
fricas
arity s
 (12)
Type: ClosedProp?(ClosedLinearOperator(OrderedVariableList([x,y]),Expression(Integer)))
fricas
2*s
 (13)
Type: ClosedLinearOperator(OrderedVariableList([x,y]),Expression(Integer))
fricas
s*2
 (14)
Type: ClosedLinearOperator(OrderedVariableList([x,y]),Expression(Integer))

Powers

fricas
A^p
 (15)
Type: ClosedLinearOperator(OrderedVariableList([x,y]),Expression(Integer))
fricas
a^p
 (16)
Type: ClosedProp?(ClosedLinearOperator(OrderedVariableList([x,y]),Expression(Integer)))

fricas
s/A
0 +
- -
0 +
arity warning: ---
0 +
- -
0 +
 (17)
Type: ClosedLinearOperator(OrderedVariableList([x,y]),Expression(Integer))
fricas
A/s
+ 0
- -
+ 0
arity warning: ---
+ 0
- -
+ 0
 (18)
Type: ClosedLinearOperator(OrderedVariableList([x,y]),Expression(Integer))
fricas
3*A
 (19)
Type: ClosedLinearOperator(OrderedVariableList([x,y]),Expression(Integer))
fricas
A/3
+ 0
- -
+ 0
arity warning: ---
+ 0
- -
+ 0
 (20)
Type: ClosedLinearOperator(OrderedVariableList([x,y]),Expression(Integer))

identities

fricas
I:L := [1]
 (21)
Type: ClosedLinearOperator(OrderedVariableList([x,y]),Expression(Integer))
fricas
I*I
 (22)
Type: ClosedLinearOperator(OrderedVariableList([x,y]),Expression(Integer))
fricas
arity(I*I)
 (23)
Type: ClosedProp?(ClosedLinearOperator(OrderedVariableList([x,y]),Expression(Integer)))
fricas
I/I
 (24)
Type: ClosedLinearOperator(OrderedVariableList([x,y]),Expression(Integer))
fricas
H:L:=[1,2]
 (25)
Type: ClosedLinearOperator(OrderedVariableList([x,y]),Expression(Integer))
fricas
arity(H)
 (26)
Type: ClosedProp?(ClosedLinearOperator(OrderedVariableList([x,y]),Expression(Integer)))
fricas
eval(I*I)
 (27)
Type: ClosedLinearOperator(OrderedVariableList([x,y]),Expression(Integer))
fricas
arity eval(I*I)
 (28)
Type: ClosedProp?(ClosedLinearOperator(OrderedVariableList([x,y]),Expression(Integer)))
fricas
test( I*I = H )
 (29)
Type: Boolean
fricas
-- twist
X:L := [2,1]
 (30)
Type: ClosedLinearOperator(OrderedVariableList([x,y]),Expression(Integer))
fricas
test(X/X=H)
 (31)
Type: Boolean
fricas
test(X/H=X)
 (32)
Type: Boolean
fricas
test(H/X=X)
 (33)
Type: Boolean
fricas
-- printing
I*X*X*I
 (34)
Type: ClosedLinearOperator(OrderedVariableList([x,y]),Expression(Integer))
fricas
(I*X*X*I)/(X*I*I*X)
 (35)
Type: ClosedLinearOperator(OrderedVariableList([x,y]),Expression(Integer))
fricas
-- trace
U:L:=ev(1)
 (36)
Type: ClosedLinearOperator(OrderedVariableList([x,y]),Expression(Integer))
fricas
Ω:L:=co(1)
 (37)
Type: ClosedLinearOperator(OrderedVariableList([x,y]),Expression(Integer))
fricas
Ω/U
 (38)
Type: ClosedLinearOperator(OrderedVariableList([x,y]),Expression(Integer))
fricas
test
( I Ω  ) /
(  U I ) = I
 (39)
Type: Boolean
fricas
test
(  Ω I ) /
( I U  ) = I
 (40)
Type: Boolean

Back to the top.