vermaseren / form

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

A question on constrained wildcarding #333

Closed vsht closed 4 years ago

vsht commented 4 years ago

Hi,

suppose that I want to have an id statement that works only when the arguments are distinct, e.g. f(p1,p2) should become g(p1,p2), but f(p1,p1) must remain as it is. The following code works as expected:

V p1,p2,q1,q2;
CF f,g;
L ex = f(p1,p1);
id f(q1?,q2?!{q1?}) = g(q1,q2);
.sort
print;
.end

However, if I apply the set check to the first argument instead of the second one, the restriction doen't work anymore and I obtain g(p1,p1):

V p1,p2,q1,q2;
CF f,g;
L ex = f(p1,p1);
id f(q1?!{q2?},q2?) = g(q1,q2);
.sort
print;
.end

I understand that this is probably due to the way how FORM orders suitable matches, but I'm somewhat worried that if f would be a symmetric or an antisymmetric function, it might not be possible to guess which pattern FORM chooses first.

Perhaps there is also a safer way to achieve what I'm after.

Cheers, Vladyslav

vermaseren commented 4 years ago

It is mentioned in the Form course (and possibly also the manual) that the only safe way to do this is f(p1?!{p2},p2?!{p1}) because the order in which Form does this is noy specified and can change between versions.

Jos

On 15 Nov 2019, at 19:18, Vladyslav Shtabovenko notifications@github.com wrote:

Hi,

suppose that I want to have an id statement that works only when the arguments are distinct, e.g. f(p1,p2) should become g(p1,p2), but f(p1,p1) must remain as it is. The following code works as expected:

V p1,p2,q1,q2; CF f,g; L ex = f(p1,p1); id f(q1?,q2?!{q1?}) = g(q1,q2); .sort print; .end However, if I apply the set check to the first argument instead of the second one, the restriction doen't work anymore and I obtain g(p1,p1):

V p1,p2,q1,q2; CF f,g; L ex = f(p1,p1); id f(q1?!{q2?},q2?) = g(q1,q2); .sort print; .end I understand that this is probably due to the way how FORM orders suitable matches, but I'm somewhat worried that if f would be a symmetric or an antisymmetric function, it might not be possible to guess which pattern FORM chooses first.

Perhaps there is also a safer way to achieve what I'm after.

Cheers, Vladyslav

— 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/333?email_source=notifications&email_token=ABJPCERJMZID25LMSOKZ33LQT3RXRA5CNFSM4JN6Q4LKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HZVY4NQ, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABJPCEQEGG343BFA46UQ223QT3RXRANCNFSM4JN6Q4LA.

vsht commented 4 years ago

Thanks a lot for the very fast reply!