from numpy import matrix
from math import trunc
from math import sqrt
table1=matrix([[0,1],[0,1]])
def size(a):
return trunc(sqrt(a.size))
def inrange(a,b,max):
return a>=0 and b>=0 and a<max and b<max
def finbin(a,b,op):
if inrange(a,b,size(op)):
return op[a,b]
else:
return False
def assoc(op):
for a in range(size(op)):
for b in range(size(op)):
for c in range(size(op)):
x1=finbin(finbin(a,b,op),c,op)
x2=finbin(a,finbin(b,c,op),op)
#print "(",a,b,")",c,"=",x1,"?", x2,"=", a,"(",b,c,")"
if x1!=x2:
return False
return True
for a in range(2):
for b in range(2):
for c in range(2):
for d in range(2):
print a,b,c,d,assoc(matrix([[a,b],[c,d]])