galgebra icon indicating copy to clipboard operation
galgebra copied to clipboard

Use subclasses of sympy.Expr to replace the Mv class

Open eric-wieser opened this issue 4 years ago • 6 comments

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.

eric-wieser avatar Nov 27 '19 17:11 eric-wieser

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.

meuns avatar Nov 27 '19 17:11 meuns

I finally read the gist and find it quite neat. One concern, should we use the private _sympifyit?

utensil avatar Nov 29 '19 14:11 utensil

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

eric-wieser avatar Nov 29 '19 15:11 eric-wieser

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.

utensil avatar Nov 30 '19 03:11 utensil

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).

eric-wieser avatar Apr 24 '20 16:04 eric-wieser

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

utensil avatar Jun 02 '20 13:06 utensil