Why don't the algebraic structures of a type S extend to HomogeneousAggregate S?

3 views
Skip to first unread message

Neven Sajko

unread,
Dec 9, 2021, 2:38:37 AM12/9/21
to fricas-devel
Hello,

Suppose there's a function like this:

f(a, b, c, g) == vector([matrix([[g(i, j, k) for k in 1..c] for j in
1..b]) for i in 1..a])

And then if I try to do something like this:

f(2, 3, 5, (i, j, k) +-> i * j * k) + f(2, 3, 5, (i, j, k) +-> i + j + k)

or this

f(2, 3, 5, (i, j, k) +-> i * j * k) - f(2, 3, 5, (i, j, k) +-> i + j + k)

... I get an error about the missing library operation.

At first I thought: why not make Vector(R) be an AbelianGroup if R is
an AbelianGroup. And make Matrix(R) be an AbelianGroup if R is an
AbelianGroup.

After thinking about it some more, I'm actually not sure why couldn't
every HomogeneousAggregate(S) have AbelianGroup if S is an
AbelianGroup. And other algebraic structures apart from AbelianGroup,
too.

Thanks,
Neven

Ralf Hemmecke

unread,
Dec 9, 2021, 4:15:11 AM12/9/21
to fricas...@googlegroups.com
> Suppose there's a function like this:
>
> f(a, b, c, g) == vector([matrix([[g(i, j, k) for k in 1..c] for j in
> 1..b]) for i in 1..a])
>
> And then if I try to do something like this:
>
> f(2, 3, 5, (i, j, k) +-> i * j * k) + f(2, 3, 5, (i, j, k) +-> i + j + k)
>
> or this
>
> f(2, 3, 5, (i, j, k) +-> i * j * k) - f(2, 3, 5, (i, j, k) +-> i + j + k)
>
> ... I get an error about the missing library operation.

> At first I thought: why not make Vector(R) be an AbelianGroup if R is
> an AbelianGroup. And make Matrix(R) be an AbelianGroup if R is an
> AbelianGroup.

Neither of which is mathematically correct. What would you expect to get
for this:

vector [1] + vector [2,3]

? AbelianSemiGroup requires the + operation to be a total function.

> After thinking about it some more, I'm actually not sure why couldn't
> every HomogeneousAggregate(S) have AbelianGroup if S is an
> AbelianGroup. And other algebraic structures apart from AbelianGroup,
> too.

Of course it might be questionable whether the condition for the export
of + from Vector (namely "if R has AbelianSemiGroup") is a good choice.
http://fricas.github.io/api/VectorCategory.html#l566563746f7243617465676f7279-2b

Given that the + for Vector is a partial function anyway, it would have
been enough to just require that the parameter domain R of Vector
provides an operation +: (%, %)->% even if it is neither commutative nor
does fulfil any other "good" properties. But do we really want this?

If you know what your matrix sizes are and what your vector sizes are,
then you should be able to program (in a .spad file) a domain

N ==> NonNegativeinteger
VectorMatrix(m: N, n: N, d: N, R: Join(SemiRng, AbelianMonoid)): E == I
where
M ==> RectangularMatrix(m, n, R)
E ==> DirectProductCategory(d, M) with
create: ((N,N,N) -> R) -> %
I ==> DirectProduct(d, M) add
create(g: (N,N,N) -> R): % ==
directProduct vector [_
rectangularMatrix matrix(_
[[g(i, j, k) for k in 1..n] for j in 1..m])_
for i in 1..d]

WARNING: I haven't tested the code above, but hopefully you see how it
could go.

You should be able to add two elements of the above "VectorMatrix".

Ralf
Reply all
Reply to author
Forward
0 new messages