Ask Your Question

Revision history [back]

You may create a dictionary of variables:

import itertools
S = {}
for i,j,k,l in itertools.product([1..4], repeat=4):
    S[(i,j,k,l)] = var('S_{}{}{}{}'.format(i,j,k,l))

which then allows you to create a loop to set your relations.

Alternatively, you may create only the variable S_ijkl in the loop above and add a line for the others:

for i,j,k,l in itertools.product([1..4], repeat=4):
    if j>i or l>k:
        continue
    S[(i,j,k,l)] = var('S_{}{}{}{}'.format(i,j,k,l))
    S[(j,i,k,l)] = S[(i,j,l,k)] = S[(j,i,l,k)]