On Saturday, March 22, 2014 3:26:36 PM UTC+1, Matthew wrote:
>
> > @Matthew Rocklin: would you try to generalize your multiple dispatch 
> module to pattern dispatch?
>
> The multipledispatch package will only be about dispatch against types. 
>  This package is intended for general programming and so efficiently covers 
> the common case.  
>
> However a long time ago though I was on a pattern matching and logic 
> programming kick.  There are old/derelict unify and strategies modules in 
> SymPy as a result. Most development was eventually transferred to the LogPy 
> project, an implementation of miniKanren.  Among other things it held a 
> basic unification/reification system, a dispatch system for those 
> functions, and a less basic though still inefficient 
> associative-commutative unification/reification system.  
>
> In a SymPy branch I built up LogPy/SymPy integration and played with a 
> simplification system that defined itself based on (source-pattern, 
> target-pattern, boolean condition patterns) a la
>
> Abs(x) -> x if x is positive
>
> It worked fine but was slow in the case of associative-commutative 
> operators.  I'll throw up some links below.  I suggest that if we want to 
> continue this conversation we do it on a separate issue.
>

For what I mean, pattern dispatch can be very helpful for this issue. I 
mean, I added the algorithm to simplify gamma matrices, and my conclusion 
is that tensor manipulations should be performed by a pattern 
matching/pattern dispatching system. It would be a mess to implement every 
single tensor-manipulation rule by hand with for- or while-loops.

Pattern matching efficiency is not important here, we just need an easy way 
to translate physics laws to SymPy. An API to perform pattern 
matching/pattern dispatch is what is really required here, even if it has 
non-optimized algorithms behind it, efficiency can be later improved. 
Tensors are complicated data structures, and modern physics has an enormous 
amount of possible operations on all of their parts (tensors themselves, 
their indices, their symmetry group).

I once saw a post claiming that pattern matching would also be helpful to 
the quantum module, and in fact I guess that having to write many lines of 
code to implement simple physics transformation laws can be frustrating.


> The trick behind efficient pattern matching in our case is to match an 
> input expression against all of the patterns at once.  The patterns should 
> be stored in a data structure like a Trie.  This is relatively 
> straightforward in the non-associative-commutative case but a mess in the 
> associative-commutative case.
>
>
The symmetry structure of tensors and tensor indices is more complicated. 
But maybe can avoid using these specificities with the pattern matcher.

I suggest that if Petrov gets accepted to the GSoC, we setup a pattern 
dispatcher to allow him to implement the tensor manipulation rules more 
easily during this summer. Please give me some feedback about this idea, 
I'm no expert in pattern matching algorithms and am unlikely to work on it 
if I'm alone.

>

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/d9cbd48e-5e81-415e-aa8e-1d7dcac1fc2a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to