Add test of injectivity lemma in the paper.

Signed-off-by: Daira Hopwood <daira@jacaranda.org>
This commit is contained in:
Daira Hopwood 2019-10-25 23:23:02 +01:00
parent c716927edd
commit 78b0876888
1 changed files with 22 additions and 0 deletions

22
injectivitylemma.py Normal file
View File

@ -0,0 +1,22 @@
#!/usr/bin/python
from itertools import product
def gamma_delta():
yield (-1, 0)
yield ( 1, 0)
yield ( 0, -1)
yield ( 0, 1)
def sums_mod4(gd):
return (sum([gd[j][0] * (2**j) for j in range(k)]) % 4, sum([gd[j][1] * (2**j) for j in range(k)]) % 4)
for k in (1, 2):
M_k = [list(s) for s in product(gamma_delta(), repeat=k)]
assert(len(M_k) == 4**k)
for (gd, gd_dash) in product(M_k, repeat=2):
if gd[0] != gd_dash[0]:
assert(sums_mod4(gd) != sums_mod4(gd_dash))
print("QED")