kpeeters / cadabra2

A field-theory motivated approach to computer algebra.
https://cadabra.science/
GNU General Public License v3.0
223 stars 37 forks source link

Proving world sheet supersymmetry in Python3 #59

Closed supercuerda closed 6 years ago

supercuerda commented 6 years ago

I'm working in a jupyter notebook. I wanted to translate the part 2.4 of the tutorial

https://cadabra.science/static/pdf/cadabra.pdf

on world-sheet supersymmetry. It has been humiliating however to get stuck in the first line. What is the correct syntax for:

{\del{#}, \delbar{#}}::Derivative.

In python3 the hash means commenting out. So, what should I do? What else should be aware of to continue?

kpeeters commented 6 years ago

If you look at how this is done in https://cadabra.science/static/cadabra_in_ipython.nb.html , you can see that you need to write this as

Derivative(Ex(r'{\del{#}, \delbar{#}}')

You cannot use the Cadabra syntax with '::' and ':=' inside a jupyter notebook, because at present there is no Cadabra kernel for jupyter.

supercuerda commented 6 years ago

Thanks. I'm sorry, I don't want to abuse... but still, I don't manage to properly use:

◃ {\del{#}, \delbar{#}}::Derivative. ◃ {\Psi\mu, \Psibar\mu, \eps, \epsbar}::AntiCommuting. ◃ {\Psi\mu, \Psibar\mu, \eps, \epsbar}::SelfAntiCommuting. ◃ {\Psi\mu, \Psibar\mu, X\mu}::Depends(\del,\delbar). ◃ {\Psi\mu, \Psibar\mu, \eps, \epsbar, X\mu, i}::SortOrder.

Please help me to find some documentation that I could study. For example, I would like to know what are Cadabra classes, objects, attributes, etc.

For example, I would like to be able to do things like:

Psi=CadabraObj() #Psi is a cadabra object. And then Psi.AntiCommuting() #Psi is anticommuting

Thanks for helping

kpeeters commented 6 years ago

For all of those lines in your example, take the property name ('Derivative', 'AntiCommuting' etc.) and write wrap the expression before the '::' as a string inside an 'Ex' object, so

  AntiCommuting(Ex(r'{\Psi_\mu, \Psibar_\mu, \eps, \epsbar}'))

This, for practical purposes, can be thought of as calling the function 'AntiCommuting', which associates an anti-commutativity property to the mathematical expressions in the 'Ex' object passed to it.

Things do not work they way you wrote in the 2nd part of your email. There is no such thing as 'the python object Psi'. All mathematical expressions are Cadabra Ex objects, which have their own internal idea about how things are stored. It is not like in Sympy, where you build mathematical expressions by nesting Sympy objects. The elementary building blocks of Cadabra expressions are not Python objects.

This should probably be documented and explained better (I can imagine that the above is not particularly convincing, but trust me there is a good reason for things being this way). However, as my main goal is not the use of Cadabra within jupyter, this is somewhat of a low-priority item. I'll put it on the list though. And feel free to keep asking questions.

supercuerda commented 6 years ago

Thanks for your answer. So, I imagine that it is Ex() that creates a Cadabra-class object, and AntiCommuting() is an attribute of it. I understand that there must be a logic that permits Cadabra to handle better physicist's expression, like action principles. It must be very interesting. For the moment I will work directly in Cadabra's notebook as I need to get familiarized with the syntaxis and the logic of it before working in Jupyter. I will comeback here probably in some months. Best.