vermaseren / form

The FORM project for symbolic manipulation of very big expressions
GNU General Public License v3.0
1.14k stars 136 forks source link

Crash related to id an e_ #161

Closed vsht closed 7 years ago

vsht commented 7 years ago

The following code

#procedure myreplace(from,to,what)

if (occurs(`what'));
  id `from' = `to';
endif;

#endprocedure

S Pi;
V p1,p2,p3,p4;
I i,j,xxi,xxj,xxk;
CF myeps, eps(a);

L expr = pi_*d_(i,j)*myeps(i,p1,p2)*myeps(j,p3,p4);
.sort;

sum i,j;

id myeps(xxi?,xxj?,xxk?) = -eps(xxi,xxj,xxk);
id eps(xxi?,xxj?,xxk?) = e_(xxi,xxj,xxk);
.sort

#call myreplace(pi_,Pi,pi_);

print expr;

.end

crashes with

Time =       0.00 sec    Generated terms =          1
            expr         Terms in output =          1
                         Bytes used      =         84

    #call myreplace(pi_,Pi,pi_);

    print expr;

    .end
Program terminating at test.frm Line 27 --> 
  0.00 sec out of 0.00 sec

without any further infos. The crash can be avoided if one comments out

id eps(xxi?,xxj?,xxk?) = e_(xxi,xxj,xxk);

or `

call myreplace(pi,Pi,pi);`

However, for my real code I need both statements. myeps is a totally antisymmetric tensor that I want to convert to e_. I suppose this is where the problem comes from. Nevertheless, I also cannot avoid this conversion, since I'm computing a squared amplitude and contract obviously does not know how not handle a contraction of myeps tensors.

Furthermore, also a direct conversion

    id myeps(xxi?,xxj?,xxk?) = -e_(xxi,xxj,xxk);

leads to the same crash.

Is this a bug and if yes, could someone suggest a workaround?

P.S. I'm using the latest snapshot from the master branch on Fedora 23 64-bit.

Cheers, Vladyslav

tueda commented 7 years ago

I feel this is related to #74. The bug is in occurs with expressions containing e_. In your case, pi_ is a symbol and at the ground level, so

if (count(`what',1));

instead of the use of occurs, would be a workaround.

vermaseren commented 7 years ago

Should be fixed now. The routine to look for variables in occurs didn’t recognize the special role of tensors.

Jos

On 20 dec. 2016, at 12:15, Takahiro Ueda notifications@github.com wrote:

I feel this is related to #74 https://github.com/vermaseren/form/issues/74. The bug is in occurs with expressions containing e. In your case, pi is a symbol and at the ground level, so

if (count(`what',1)); instead of the use of occurs, would be a workaround.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/vermaseren/form/issues/161#issuecomment-268218234, or mute the thread https://github.com/notifications/unsubscribe-auth/AFLxEkD5AR5TlyYI9K6alyPPcEFoS_6Cks5rJ7jugaJpZM4LRsXr.

vsht commented 7 years ago

Dear both, many thanks for the prompt reaction! Takahiro has correctly identified the issue (I was about to report that his workaround works also with my real code) and Jos has fixed it. Great!

Cheers, Vladyslav