Foreach in constraints

constraint range {foreach (a[i]) (i<31) → a[i+1]=~a[i];}

while using the abve statement , it throws the following error
near “=”: syntax error, unexpected ‘=’, expecting ++ or –

please tell the reason

Syntax is wrong . Syntax should look like this
for constraint assignment it should be used == instead of =
You should use the

constraint range {foreach (a[i]) (i<31) -> (a[i+1]==a[i]);}

In reply to kddholak:

thank u so much