Adding two square matrices of different dimension should result in an error. Axiom returns something that looks more like a tensor product.

The implementation of + for SquareMatrix? is inherited from Matrix (src/algebra/matrix.spad.pamphlet). Matrix inherits + from the default implementation in MatrixCategory? (src/algebra/matcat.spad.pamphlet).
There it says:

"+": (%,%) -> %
++ \spad{x + y} is the sum of the matrices x and y.
++ Error: if the dimensions are incompatible.

and is implemented
by default through:

x + y ==
((r := nrows x) ^= nrows y) or ((c := ncols x) ^= ncols y) =>
error "can't add matrices of different dimensions"
ans := new(r,c,0)
for i in minr(x)..maxr(x) repeat
for j in minc(x)..maxc(x) repeat
qsetelt_!(ans,i,j,qelt(x,i,j) + qelt(y,i,j))
ans

I have no idea why the following code returns something of type
SquareMatrix

?(2,SquareMatrix

?(3,Integer)).

fricas

)set message bottomup on

fricas

S d ==> SquareMatrix(d,Integer)

**Type: **Void

fricas

a2: S(2) := 1

**Type: **SquareMatrix

?(2,

Integer)
fricas

a3: S(3) := 1

**Type: **SquareMatrix

?(3,

Integer)
fricas

a2 + a3

Function Selection for +
Arguments: (SQMATRIX(2,INT),SQMATRIX(3,INT))
-> no appropriate + found in SquareMatrix(2,Integer)
-> no appropriate + found in SquareMatrix(3,Integer)
-> no appropriate + found in SquareMatrix(2,SquareMatrix(3,Integer))
-> no appropriate + found in SquareMatrix(2,Integer)
-> no appropriate + found in SquareMatrix(3,Integer)

[1] signature: (SQMATRIX(2,SQMATRIX(3,INT)),SQMATRIX(2,SQMATRIX(3,INT))) -> SQMATRIX(2,SQMATRIX(3,INT))
implemented: slot $$$ from SQMATRIX(2,SQMATRIX(3,INT))

Function Selection for map by coercion facility (map)
Arguments: ((INT -> SQMATRIX(3,INT)),SQMATRIX(2,INT))
Target type: SQMATRIX(2,SQMATRIX(3,INT))
-> no appropriate map found in SquareMatrix(2,Integer)
-> no appropriate map found in SquareMatrix(2,SquareMatrix(3,Integer))
-> no appropriate map found in SquareMatrix(3,Integer)
-> no appropriate map found in Integer
-> no appropriate map found in SquareMatrix(3,Integer)

Modemaps from Associated Packages
no modemaps

Remaining General Modemaps
[1] ((D3 -> D3),D) -> D from D
if D has XFALG(D2,D3) and D2 has ORDSET and D3 has RING
[2] ((D4 -> Union(D5,"failed")),Vector(D4)) -> Union(Vector(D5),
"failed")
from VectorFunctions2(D4,D5) if D4 has TYPE and D5 has TYPE

[3] ((D4 -> D5),Vector(D4)) -> Vector(D5) from VectorFunctions2(D4,
D5)
if D4 has TYPE and D5 has TYPE
[4] ((D4 -> D5),D3) -> D1
from UnivariateTaylorSeriesFunctions2(D4,D5,D3,D1)
if D4 has RING and D5 has RING and D1 has UTSCAT(D5) and D3
has UTSCAT(D4)
[5] ((D5 -> D6),UnivariatePuiseuxSeries(D5,D7,D9)) ->
UnivariatePuiseuxSeries(D6,D8,D1)
from UnivariatePuiseuxSeriesFunctions2(D5,D6,D7,D8,D9,D1)
if D5 has RING and D6 has RING and D7: SYMBOL and D9: D5
and D1: D6 and D8: SYMBOL
[6] ((D4 -> D5),D3) -> D1
from UnivariatePolynomialCategoryFunctions2(D4,D3,D5,D1)
if D4 has RING and D5 has RING and D1 has UPOLYC(D5) and D3
has UPOLYC(D4)
[7] ((D5 -> D7),UnivariatePolynomial(D4,D5)) -> UnivariatePolynomial
(D6,D7)
from UnivariatePolynomialFunctions2(D4,D5,D6,D7)
if D4: SYMBOL and D5 has RING and D7 has RING and D6:
SYMBOL
[8] ((D4 -> D5),UniversalSegment(D4)) -> Stream(D5)
from UniversalSegmentFunctions2(D4,D5)
if D4 has ORDRING and D4 has TYPE and D5 has TYPE
[9] ((D4 -> D5),UniversalSegment(D4)) -> UniversalSegment(D5)
from UniversalSegmentFunctions2(D4,D5)
if D4 has TYPE and D5 has TYPE
[10] ((D5 -> D6),UnivariateLaurentSeries(D5,D7,D9)) ->
UnivariateLaurentSeries(D6,D8,D1)
from UnivariateLaurentSeriesFunctions2(D5,D6,D7,D8,D9,D1)
if D5 has RING and D6 has RING and D7: SYMBOL and D9: D5
and D1: D6 and D8: SYMBOL
[11] ((D4 -> D5),SparseUnivariatePolynomial(D4)) ->
SparseUnivariatePolynomial(D5)
from SparseUnivariatePolynomialFunctions2(D4,D5)
if D4 has RING and D5 has RING
[12] ((D4 -> D5),Stream(D4)) -> Stream(D5) from StreamFunctions2(D4,
D5)
if D4 has TYPE and D5 has TYPE
[13] ((D4 -> D5),Sequence(D4)) -> Sequence(D5)
from SequenceFunctions2(D4,D5)
if D4 has COMRING and D5 has COMRING
[14] ((D3 -> D3),D) -> D1 from D
if D has SEGXCAT(D3,D1) and D3 has ORDRING and D1 has STAGG
(D3)
[15] ((D4 -> D5),SegmentBinding(D4)) -> SegmentBinding(D5)
from SegmentBindingFunctions2(D4,D5)
if D4 has TYPE and D5 has TYPE
[16] ((D4 -> D5),Segment(D4)) -> List(D5) from SegmentFunctions2(D4,
D5)
if D4 has ORDRING and D4 has TYPE and D5 has TYPE
[17] ((D4 -> D5),Segment(D4)) -> Segment(D5) from SegmentFunctions2(
D4,D5)
if D4 has TYPE and D5 has TYPE
[18] ((D9 -> D1),D6) -> D4
from RectangularMatrixCategoryFunctions2(D7,D8,D9,D10,D11,
D6,D1,D2,D3,D4)
if D9 has Join(SRNG,ABELMON) and D1 has Join(SRNG,ABELMON)
and D7: NNI and D8: NNI and D10 has DIRPCAT(D8,D9) and D11
has DIRPCAT(D7,D9) and D4 has RMATCAT(D7,D8,D1,D2,D3) and
D6 has RMATCAT(D7,D8,D9,D10,D11) and D2 has DIRPCAT(D8,D1)
and D3 has DIRPCAT(D7,D1)
[19] ((D4 -> D4),D) -> D from D
if D has RMATCAT(D2,D3,D4,D5,D6) and D4 has Join(SRNG,
ABELMON) and D5 has DIRPCAT(D3,D4) and D6 has DIRPCAT(D2,D4
)
[20] ((D4 -> D5),D3) -> D1 from QuaternionCategoryFunctions2(D3,D4,
D1,D5)
if D4 has COMRING and D5 has COMRING and D1 has QUATCAT(D5)
and D3 has QUATCAT(D4)
[21] ((D4 -> D5),D3) -> D1 from QuotientFieldCategoryFunctions2(D4,
D5,D3,D1)
if D4 has INTDOM and D5 has INTDOM and D1 has QFCAT(D5) and
D3 has QFCAT(D4)
[22] ((D4 -> D5),Point(D4)) -> Point(D5) from PointFunctions2(D4,D5)
if D4 has RING and D5 has RING
[23] ((D4 -> D5),PrimitiveArray(D4)) -> PrimitiveArray(D5)
from PrimitiveArrayFunctions2(D4,D5)
if D4 has TYPE and D5 has TYPE
[24] ((D4 -> D5),Polynomial(D4)) -> Polynomial(D5)
from PolynomialFunctions2(D4,D5)
if D4 has RING and D5 has RING
[25] ((D4 -> D5),Pattern(D4)) -> Pattern(D5) from PatternFunctions2(
D4,D5)
if D4 has SETCAT and D5 has SETCAT
[26] ((D5 -> D6),PatternMatchResult(D4,D5)) -> PatternMatchResult(D4
,D6)
from PatternMatchResultFunctions2(D4,D5,D6)
if D4 has SETCAT and D5 has SETCAT and D6 has SETCAT
[27] ((D4 -> D5),ParametricSurface(D4)) -> ParametricSurface(D5)
from ParametricSurfaceFunctions2(D4,D5)
if D4 has TYPE and D5 has TYPE
[28] ((D4 -> D5),ParametricSpaceCurve(D4)) -> ParametricSpaceCurve(
D5)
from ParametricSpaceCurveFunctions2(D4,D5)
if D4 has TYPE and D5 has TYPE
[29] ((D4 -> D5),ParametricPlaneCurve(D4)) -> ParametricPlaneCurve(
D5)
from ParametricPlaneCurveFunctions2(D4,D5)
if D4 has TYPE and D5 has TYPE
[30] ((D4 -> D5),OrderedCompletion(D4)) -> OrderedCompletion(D5)
from OrderedCompletionFunctions2(D4,D5)
if D4 has SETCAT and D5 has SETCAT
[31] ((D4 -> D5),OnePointCompletion(D4)) -> OnePointCompletion(D5)
from OnePointCompletionFunctions2(D4,D5)
if D4 has SETCAT and D5 has SETCAT
[32] ((D4 -> D5),D3) -> D1 from OctonionCategoryFunctions2(D3,D4,D1,
D5)
if D4 has COMRING and D5 has COMRING and D1 has OC(D5) and
D3 has OC(D4)
[33] ((D4 -> D5),MonoidRing(D4,D6)) -> MonoidRing(D5,D6)
from MonoidRingFunctions2(D4,D5,D6)
if D4 has RING and D5 has RING and D6 has MONOID
[34] ((D2 -> D2),D) -> D from D
if D has MRCAT(D2,D3) and D2 has RING and D3 has MONOID
[35] ((D7 -> D8),D3) -> D1 from MPolyCatFunctions2(D4,D5,D6,D7,D8,D3
,D1)
if D7 has RING and D8 has RING and D4 has ORDSET and D5 has
OAMONS and D1 has POLYCAT(D8,D6,D4) and D6 has OAMONS and
D3 has POLYCAT(D7,D5,D4)
[36] ((D5 -> Union(D8,"failed")),D4) -> Union(D2,"failed")
from MatrixCategoryFunctions2(D5,D6,D7,D4,D8,D9,D1,D2)
if D5 has Join(SRNG,ABELMON) and D8 has Join(SRNG,ABELMON)
and D6 has FLAGG(D5) and D7 has FLAGG(D5) and D2 has MATCAT
(D8,D9,D1) and D4 has MATCAT(D5,D6,D7) and D9 has FLAGG(D8)
and D1 has FLAGG(D8)
[37] ((D5 -> D8),D4) -> D2
from MatrixCategoryFunctions2(D5,D6,D7,D4,D8,D9,D1,D2)
if D5 has Join(SRNG,ABELMON) and D8 has Join(SRNG,ABELMON)
and D6 has FLAGG(D5) and D7 has FLAGG(D5) and D2 has MATCAT
(D8,D9,D1) and D4 has MATCAT(D5,D6,D7) and D9 has FLAGG(D8)
and D1 has FLAGG(D8)
[38] ((D4 -> D5),List(D4)) -> List(D5) from ListFunctions2(D4,D5)
if D4 has TYPE and D5 has TYPE
[39] ((D2 -> D2),InfiniteTuple(D2)) -> InfiniteTuple(D2)
from InfiniteTuple(D2) if D2 has TYPE
[40] ((D4 -> D5),InfiniteTuple(D4)) -> InfiniteTuple(D5)
from InfiniteTupleFunctions2(D4,D5)
if D4 has TYPE and D5 has TYPE
[41] ((D4 -> D5),Union(Record(mainpart: D4,limitedlogs: List(Record(
coeff: D4,logand: D4))),"failed")) -> Union(Record(mainpart: D5,
limitedlogs: List(Record(coeff: D5,logand: D5))),"failed")
from IntegrationResultFunctions2(D4,D5)
if D4 has FIELD and D5 has FIELD
[42] ((D4 -> D1),Union(D4,"failed")) -> Union(D1,"failed")
from IntegrationResultFunctions2(D4,D1)
if D4 has FIELD and D1 has FIELD
[43] ((D4 -> D5),Union(Record(ratpart: D4,coeff: D4),"failed")) ->
Union(Record(ratpart: D5,coeff: D5),"failed")
from IntegrationResultFunctions2(D4,D5)
if D4 has FIELD and D5 has FIELD
[44] ((D4 -> D5),IntegrationResult(D4)) -> IntegrationResult(D5)
from IntegrationResultFunctions2(D4,D5)
if D4 has FIELD and D5 has FIELD
[45] ((D2 -> D2),D) -> D from D
if D has IDPC(D2,D3) and D2 has SETCAT and D3 has COMPAR

[46] ((D2 -> D2),D) -> D from D if D has HOAGG(D2) and D2 has TYPE

[47] ((D4 -> D5),D3) -> D1 from FiniteSetAggregateFunctions2(D4,D3,
D5,D1)
if D4 has SETCAT and D5 has SETCAT and D1 has FSAGG(D5) and
D3 has FSAGG(D4)
[48] ((D4 -> D5),D3) -> D1 from FunctionSpaceFunctions2(D4,D3,D5,D1)
if D4 has Join(RING,COMPAR) and D5 has Join(RING,COMPAR)
and D1 has FS(D5) and D3 has FS(D4)
[49] ((D4 -> D5),D3) -> D1
from FramedNonAssociativeAlgebraFunctions2(D3,D4,D1,D5)
if D4 has COMRING and D5 has COMRING and D1 has FRNAALG(D5)
and D3 has FRNAALG(D4)
[50] ((D7 -> D11),FractionalIdeal(D7,D8,D9,