1. 15
  1.  

  2.  

    As far as I can tell, the only systems that have a real answer to the commutativity problem (and similar) are term-rewriting systems using e-graphs: declare that x + y = y + x, and then try both expansions, picking whichever gives the ultimate result you like better.

    1.  

      Rust could support “intelligent” commutative operations (to the extent of even distinguishing between allowed and disallowed addition/multiplication of matrices) with its recent improvements to const generics if it let you define a commutative trait like the ones in the article (that don’t compile) and then you used const math generic constraints to define the requirements on M and N as it’s purely based off the shape of a matrix that math is allowed.

      1.  

        That is not a general solution. What do you do if x+y and y+x are both valid?