galgebra
galgebra copied to clipboard
Use subclasses of sympy.Expr to replace the Mv class
Mirroring a slack post here for public discussion:
I did some experimentation regarding tighter sympy integration: https://gist.github.com/eric-wieser/823a115df88b6e96e21fdedebbdfa9c0 The eventual idea here would be to eliminate Mv in favor of a subclass of GaExpr. It also opens the door for working symbolically without having to do so one basis blade at a time.
I'll expand on this idea in future.
I wrote a very hacky thing following the same approach but it was quite clear sympy was useless manipulating the resulting expressions (very large polynomials expressions). I'm interested to follow this work, maybe you will find nice ways to tie GA and sympy together. On the other hand, I started to read a lot of papers about doing geometric proofs using computers. Most of them are wrote by Hongbo Li, he also wrote a nice book (https://www.amazon.com/Invariant-Algebras-Geometric-Reasoning-Hongbo/dp/9812708081). I'm still trying to find an implementation.
I finally read the gist and find it quite neat. One concern, should we use the private _sympifyit
?
One concern, should we use the private
Sympy has not been built for ease of writing extension algebras - we have little choice but to call private methods if we want to actually integrate with rather than just depend on sympy
If we're going to use private methods (as an important design dependency) in SymPy, it's better to bring the discussion to SymPy and possibly submit PRs to make it part of the API.
Found a useful part of the (private) sympy API, _constructor_postprocessor_mapping
(example here)
https://github.com/sympy/sympy/blob/master/sympy/core/basic.py#L1793-L1822
This would allow us to overload Add(mv, mv)
.
I believe the equivalence of this is happening already, only in a different approach: https://github.com/pygae/galgebra/commits/master/galgebra/atoms.py . Should we close this? @eric-wieser