spad
)abbrev domain LFREEMOD LeftFreeModule
LeftFreeModule(R: Ring, S: OrderedSet):
    Join(LeftModule R, IndexedDirectProductCategory(R,S)) with
      linearCombination: List Pair(S,R) -> %
 == IndexedDirectProductAbelianGroup(R,S) add
   Rep == List Pair(S,R)
   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 [pair(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 [pair(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
   Compiling FriCAS source code from file 
      /var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/833505762114505642-25px001.spad
      using old system compiler.
   LFREEMOD abbreviates domain LeftFreeModule 
------------------------------------------------------------------------
   initializing NRLIB LFREEMOD for LeftFreeModule 
   compiling into NRLIB LFREEMOD 
****** comp fails at level 1 with expression: ******
((|IndexedDirectProductAbelianGroup| R S))
****** level 1  ******
$x:= (IndexedDirectProductAbelianGroup R S)
$m:= $EmptyMode
$f:=
((((~= #) (= #) (|coerce| #) (|hash| #) ...)))
   >> Apparent user error:
   cannot compile (IndexedDirectProductAbelianGroup R S)There is no from LeftFreeModule? printed out.
axiom
x := 'x::OrderedVariableList ['x,'y]
Type: OrderedVariableList
?([x,
y])
 
axiom
x := 'y::OrderedVariableList ['x,'y]
Type: OrderedVariableList
?([x,
y])
 
axiom
2 * linearCombination([pair(x,2), pair(y,3)])$LeftFreeModule(Integer,OrderedVariableList ['x,'y])
   LeftFreeModule is an unknown constructor and so is unavailable. Did 
      you mean to use -> but type something different instead?
Integer has EntireRing
Type: Boolean
axiom
(2 * linearCombination([pair(x,2), pair(y,3)])$LeftFreeModule(Integer,OrderedVariableList ['x,'y]))$LeftFreeModule(Integer,OrderedVariableList ['x,'y])
   LeftFreeModule is an unknown constructor and so is unavailable. Did 
      you mean to use -> but type something different instead?