Skip to content

Sums and products over arbitrary finite types #1367

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 47 commits into
base: master
Choose a base branch
from

Conversation

lowasser
Copy link
Collaborator

In preparation for polynomials and formal power series, most notably multiplication of formal power series (#1357), this starts digging into sums over arbitrary finite types, and generalizes from sums on e.g. semirings to products on monoids -- mostly commutative monoids, since they're the ones where arbitrary finite sums make sense.

There is some tension with naming over whether group-theory.products-monoids should indicate the monoid on the Cartesian product of two other monoids, or products of elements in a monoid. Since monoids (and groups in general) use multiplicative terminology, we can't get away with what rings have done by differentiating sums and products. (And we don't have any support for products of elements of rings, either, though the generalization to commutative monoids is intended to make that possible down the road.)

This is marked a draft because there's one last thing I want to prove, which is that you can split sums over coproducts of arbitrary finite types.

@lowasser lowasser marked this pull request as ready for review March 17, 2025 01:17
@fredrik-bakke
Copy link
Collaborator

fredrik-bakke commented Mar 17, 2025

There is some tension with naming over whether group-theory.products-monoids should indicate the monoid on the Cartesian product of two other monoids, or products of elements in a monoid. Since monoids (and groups in general) use multiplicative terminology, we can't get away with what rings have done by differentiating sums and products. (And we don't have any support for products of elements of rings, either, though the generalization to commutative monoids is intended to make that possible down the road.)

Some patterns we've used elsewhere to differentiate are the following:

  1. In foundation we use "cartesian product" for the construction taking the cartesian product of two (underlying carrier) types.
  2. In category-theory we write "products of categories" and "products in categories" to distinguish between two notions of product (*although both are about products of objects in some category, not about multiplication operations in your sense).
  3. For Minkowski products we used "Minkowski multiplication" to disambiguate from products of carrier types.

Depending on the generality of the relevant binary operation (i.e., is it associative, does it distribute over the underlying binary operation?), you might want to go with simply "binary operations on monoids", or something other than "product".

@fredrik-bakke
Copy link
Collaborator

I think "cartesian product" may be appropriate in this setting, to disambiguate from the "free product of monoids" which, perhaps counterintuitively, is the coproduct in the category of monoids.

@lowasser
Copy link
Collaborator Author

FWIW, I discovered that a very early attempt at the precise operation we want already existed in group-theory.products-of-tuples-of-elements-commutative-monoids.lagda.md. I have moved all the logic there and adopted the existing naming conventions there.

where

cons-mul-fin-Commutative-Monoid :
(n : ℕ) (f : functional-vec-Commutative-Monoid M (succ-ℕ n)) →
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

implicit n

cons-mul-fin-Monoid (monoid-Commutative-Monoid M)

snoc-mul-fin-Commutative-Monoid :
(n : ℕ) (f : functional-vec-Commutative-Monoid M (succ-ℕ n)) →
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

implicit n

where

extend-mul-fin-Commutative-Monoid :
(n : ℕ) (f : functional-vec-Commutative-Monoid M n) →
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

implicit n

mul-fin-unit-Monoid (monoid-Commutative-Monoid M)
```

### Splitting products
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a short explanation of what "splitting products" means? I.e.

Given an `n+m`-dimensional vector `f`, the product of its coordinates computes as...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this file is all about products of finite families of elements, rather than just tuples, I think a better name for this file is products-finite-families-of-elements-commutative-monoids

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, a better way to organize this is to add a second file about products of finite families of elements where you consider types A with a counting, or a proof that A is finite.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't forget to add links both ways between these files

( eq-permutation-list-standard-transpositions-Fin n σ)
```

### Products for a count for a type
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This subsection should be in the Definitions* section

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On second thought, this should be factored to a new file.

Comment on lines +184 to +186
### Splitting products

```agda
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add an explanation for what splitting products means here as well

Comment on lines +62 to +66
The product operation extends the binary multiplication operation on a
[commutative monoid](group-theory.commutative-monoids.md) `M` to any family of
elements of `M` indexed by a
[standard finite type](univalent-combinatorics.standard-finite-types.md), or to
any [finite type](univalent-combinatorics.finite-types.md).
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After splitting up the file:

Suggested change
The product operation extends the binary multiplication operation on a
[commutative monoid](group-theory.commutative-monoids.md) `M` to any family of
elements of `M` indexed by a
[standard finite type](univalent-combinatorics.standard-finite-types.md), or to
any [finite type](univalent-combinatorics.finite-types.md).
We extend the binary multiplication operation on a
[commutative monoid](group-theory.commutative-monoids.md) `M` to any family of
elements of `M` indexed by a
[standard finite type](univalent-combinatorics.standard-finite-types.md).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel free to also try and jam in a concept macro invocation for "product" Disambiguation="of a family of elements in a commutative monoid over a standard finite type" if you want

where

shift-mul-fin-Commutative-Monoid :
(n : ℕ) (f : functional-vec-Commutative-Monoid M n) →
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

implicit n


```agda
mul-fin-Monoid :
{l : Level} (M : Monoid l) (n : ℕ) →
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

implicit n in this file as well?

Comment on lines +77 to +96
(n : ℕ) → functional-vec-Commutative-Monoid (succ-ℕ n) →
type-Commutative-Monoid M
head-functional-vec-Commutative-Monoid =
head-functional-vec-Monoid (monoid-Commutative-Monoid M)

tail-functional-vec-Commutative-Monoid :
(n : ℕ) → functional-vec-Commutative-Monoid (succ-ℕ n) →
functional-vec-Commutative-Monoid n
tail-functional-vec-Commutative-Monoid =
tail-functional-vec-Monoid (monoid-Commutative-Monoid M)

cons-functional-vec-Commutative-Monoid :
(n : ℕ) → type-Commutative-Monoid M →
functional-vec-Commutative-Monoid n →
functional-vec-Commutative-Monoid (succ-ℕ n)
cons-functional-vec-Commutative-Monoid =
cons-functional-vec-Monoid (monoid-Commutative-Monoid M)

snoc-functional-vec-Commutative-Monoid :
(n : ℕ) → functional-vec-Commutative-Monoid n →
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, can these n's be made implicit?

Comment on lines +174 to +178
(n : ℕ) (v w : functional-vec-Monoid M n) → functional-vec-Monoid M n
add-functional-vec-Monoid n = binary-map-functional-vec n (mul-Monoid M)

associative-add-functional-vec-Monoid :
(n : ℕ) (v1 v2 v3 : functional-vec-Monoid M n) →
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

implicit n?

Comment on lines +45 to +46
[standard finite type](univalent-combinatorics.standard-finite-types.md), or by
a [finite type](univalent-combinatorics.finite-types.md).
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to be consistent with commutative monoids, this file can be split into two: one for tuples and one for finite families of elements

Comment on lines +49 to +50
[standard finite type](univalent-combinatorics.standard-finite-types.md), or by
a [finite type](univalent-combinatorics.finite-types.md).
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, to be consistent with commutative monoids, this can also be split into two files.

Co-authored-by: Fredrik Bakke <fredrbak@gmail.com>
@lowasser
Copy link
Collaborator Author

lowasser commented May 2, 2025

I declare this blocked on #1397, so we can get the better names for things.

@lowasser lowasser marked this pull request as draft May 2, 2025 18:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants