vermaseren / form

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

Unresolved setelement during substitution #407

Closed TomSteu closed 2 years ago

TomSteu commented 2 years ago

Dear FORM team,

I've encountered a curious issue today, I wrote some code that terminated a long computation with Unresolved setelement during substitution. I think this is happening on calling .sort or .end.

Unfortunately, I am quite puzzled by this -- I can get collect a very long list of terms with print "%t"; (print;alone does not work, the error occurs before the output) but I am not sure what to look for in there.

Could you guys give me a hint what this error means, then I can construct some minimal case where things go wrong. Sorry for not providing a sample of code.

cheers, Tom

tueda commented 2 years ago

Well, what I would say for now is maybe: are you using any wildcard substitutions with sets? The error message looks related to something wrong that happened during them.

For your information: the error message is in ResolveSet (wildcard.c)

https://github.com/vermaseren/form/blob/2a37fd21dd22e7f1a90c4956c4adf50555f7bd07/sources/wildcard.c#L1363

which is only called in WildFill:

https://github.com/vermaseren/form/blob/2a37fd21dd22e7f1a90c4956c4adf50555f7bd07/sources/wildcard.c#L611

vermaseren commented 2 years ago

This error occurs typically when you have wildcarding involving set elements as in: Symbols a1,…,a9,x,n; Set aa:a1,…,a9;

id x^n? = aa[n];

If the wildcard n gets a value outside the range 1 to 9 you will get this error message. The safe code would be if ( ( count(x,1) > 0 ) && ( count(x,1) <= 9 ) ); id x^n? = aa[n]; else;

I hope this helps.

On 30 Mar 2022, at 18:46, TomSteu @.***> wrote:

Dear FORM team,

I've encountered a curious issue today, I wrote some code that terminated a long computation with Unresolved setelement during substitution. I think this is happening on calling .sort or .end.

Unfortunately, I am quite puzzled by this -- I can get collect a very long list of terms with print "%t"; (print;alone does not work, the error occurs before the output) but I am not sure what to look for in there.

Could you guys give me a hint what this error means, then I can construct some minimal case where things go wrong. Sorry for not providing a sample of code.

cheers, Tom

— Reply to this email directly, view it on GitHub https://github.com/vermaseren/form/issues/407, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABJPCEXLKSRZAWHWMIO4WULVCSAMXANCNFSM5SCRGLZQ. You are receiving this because you are subscribed to this thread.

tueda commented 2 years ago

This error occurs typically when you have wildcarding involving set elements as in: Symbols a1,…,a9,x,n; Set aa:a1,…,a9; id x^n? = aa[n];

I guess this is a bit different problem: running

Symbols a1,...,a9,x,n;
Set aa:a1,...,a9;
Local F = x^10;
id x^n? = aa[n];
.end

gives a different error:

Array bound check during set substitution
    value is 10
Program terminating at test.frm Line 4 -->

which is in

https://github.com/vermaseren/form/blob/2a37fd21dd22e7f1a90c4956c4adf50555f7bd07/sources/wildcard.c#L1434-L1435

The problem with Unresolved setelement ... occurs before coming the label GotOne. (I have no experience with this error message and have no ideas what the code is doing...)

TomSteu commented 2 years ago

Thank you for the hints, I found my mistake. It was indeed some nonsense with a half-integer set position like this:


Symbols a1,...,a9,n;
CFunction cfun;
Set aa:a1,...,a9;

Local F = cfun(1/2);

id cfun(n?) = aa[n];
.end