fricas
(1) -> <spad>
fricas
)abbrev domain LFREEMOD LeftFreeModule
LeftFreeModule(R: Ring, S: OrderedSet):
    Join(LeftModule R, IndexedDirectProductCategory(R,S)) with
      linearCombination: List Product(S,R) -> %
 == IndexedDirectProductObject(R,S) add
   Rep := List Product(S,R)
   rep x ==> (x@%) pretend Rep
   per x ==> (x@Rep) pretend %
   linearCombination x ==
     per [u for u in x | second u ~= 0$R ]
   if R has EntireRing then
     (r: R) * (x: %) ==
       r = 0$R => 0$%
       r = 1$R => x
       messagePrint("from LeftFreeModule")$OutputForm
       per [construct(first u, r * second u) for u in rep x]
   else
     (r: R) * (x: %) ==
       r = 0$R => 0$%
       r = 1$R => x
       messagePrint("from LeftFreeModule")$OutputForm
       per [construct(first u,c) for u in rep x | (c := r *second u) ~= 0$R]
   coerce(x: %): OutputForm ==
     x' := rep x
     null x' => 0$R :: OutputForm
     res : List OutputForm := nil
     for u in reverse x' repeat
       second u = 1$R => res := cons(first(u)::OutputForm, res)
       res := cons(second(u)::OutputForm * first(u)::OutputForm, res)
     reduce("+",res)</spad>
fricas
Compiling FriCAS source code from file 
      /var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/5896234725235034910-25px001.spad
      using old system compiler.
   LFREEMOD abbreviates domain LeftFreeModule 
------------------------------------------------------------------------
   initializing NRLIB LFREEMOD for LeftFreeModule 
   compiling into NRLIB LFREEMOD 
   processing macro definition rep x ==> pretend(@(x,%),Rep) 
   processing macro definition per x ==> pretend(@(x,Rep),%) 
   compiling exported linearCombination : List Product(S,R) -> %
Time: 0.02 SEC.
****** Domain: R already in scope
augmenting R: (EntireRing)
   compiling exported * : (R,%) -> %
Time: 0 SEC.
   compiling exported * : (R,%) -> %
Time: 0 SEC.
   compiling exported coerce : % -> OutputForm
****** comp fails at level 4 with expression: ******
error in function coerce 
(SEQ (|:=| |x'| (|pretend| (@ |x| %) |Rep|))
     (|exit| 1
      (IF | << |
          (|null| |x'|)
          | >> |
          (|::| (|Sel| R 0) (|OutputForm|))
          (SEQ (|:=| (|:| |res| (|List| (|OutputForm|))) |nil|)
               (REPEAT (IN |u| (|reverse| |x'|))
                       (SEQ
                        (|:=| (|:| #1=#:G4 (|Boolean|))
                         (= (|second| |u|) (|Sel| R 1)))
                        (|exit| 1
                         (IF #1#
                             (|:=| |res|
                              (|cons| (|::| (|first| |u|) (|OutputForm|))
                               |res|))
                             (|:=| |res|
                              (|cons|
                               (* (|::| (|second| |u|) (|OutputForm|))
                                  (|::| (|first| |u|) (|OutputForm|)))
                               |res|))))))
               (|exit| 1 (|reduce| "+" |res|))))))
****** level 4  ******
x:= (null x')
m:= (Boolean)
f:=
((((|x'| #) (|x| # #) (|per| #) (|rep| #) ...)))
   >> Apparent user error:
   NoValueMode
    is an unknown modeThere is no from LeftFreeModule? printed out.
fricas
oV := OrderedVariableList ['x,'y]
Type: Type
fricas
Pro := Product(oV, Integer)
Type: Type
fricas
x := 'x::OrderedVariableList ['x,'y]
fricas
x := 'y::OrderedVariableList ['x,'y]
fricas
2 * linearCombination([construct(x,2)$Pro, construct(y,3)$Pro])$LeftFreeModule(Integer,OrderedVariableList ['x,'y])
   LeftFreeModule is an unknown constructor and so is unavailable. Did 
      you mean to use -> but type something different instead?