
Rust implementations of abstract algebraic structures - alex_hirner
https://gitlab.com/ornamentist/un-algebra
======
reikonomusha
In my opinion, the best way to learn about abstract algebraic structures is to
sit down with a book and write some proofs. That’s the purpose of these
structures, to provide a minimal language for describing the behavior of
mathematical objects for the purpose of exposition or proof. For example,
prove that given any element g of a finite group G that there exists a
positive integer k such that g^k is the identity element.

“Implementing” (with big scare quotes) algebraic structures by essentially
implementing what appear to be “interfaces” (or traits or type classes or ...)
might give you a brief “aha!” about what an abstract algebraic structure is on
the surface, but won’t give much insight or practical use beyond that.
Critically, one of the many hugely lacking aspects in this approach to
implementing these structures in a language like Rust (or Haskell or ...) is
that one needs to prove that these interfaces satisfy the axiomatic laws of
the structure.

I maintain a library that allows one to compute with groups of permutations.
The entire library—thousands of lines of fiddly code—is dedicated to one and
only one algebraic structure (the group) on one and only one kind of object
(the permutation). Countless papers have been written about just this
combination, and should give you some appreciation for the depth of this
subject. Slapping on a “identity” and “mul” implementation to a “Permutation”
object doesn’t do justice.

~~~
moomin
As you say, the big problem is you can’t express rules. I don’t think that
rules out using code to understand these things, but you’re better off
starting with something like LEAN.

~~~
reikonomusha
It’s one of the issues. The other is that you quickly will want to work with
these algebraic structures as objects themselves. When the algebraic structure
is encoded as a protocol, you won’t be able to manipulate them as first-class
values. For instance, you’ll want this if you want to do things like
factorizing groups, constructing products (like the semi direct product),
computing graded algebras, computing homomorphisms, constructing Groebner
bases, etc.

~~~
moomin
Yeah, you need dependent typing to do that in a programming language. But as
cool as dependently typed languages are, developing serious software in them
remains a bit of a research problem. Idris is closest, but it also less
convenient for actual proofs.

------
rklaehn
Looks very nice and straightforward. Otherwise, seems similar to alga:
[https://docs.rs/alga/0.9.2/alga/](https://docs.rs/alga/0.9.2/alga/)

