Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download
Views: 8800
1
2
#*****************************************************************************
3
# Copyright (C) 2016 Paul Leopardi [email protected]
4
#
5
# Distributed under the terms of the GNU General Public License (GPL)
6
# as published by the Free Software Foundation; either version 2 of
7
# the License, or (at your option) any later version.
8
# http://www.gnu.org/licenses/
9
#*****************************************************************************
10
11
from sage.crypto.boolean_function import BooleanFunction
12
13
from boolean_cayley_graphs.boolean_function_improved import BooleanFunctionImproved
14
15
16
def check_bent_isomorphism(dim, k, certify=False):
17
r"""
18
Given the non-negative numbers $dim$ and $k$, `check_bent_isomorphism`
19
checks that all of the bent functions whose truth table has $k$ bits
20
set out of the $2^{dim}-1$ non-zero bits, have isomorphic Cayley graphs.
21
It does so by enumerating all combinations `a` with $k$ non-zero bits set,
22
testing if `a` yields a bent function, then testing the resulting
23
Cayley graph for isomorphism to the first graph so obtained.
24
25
If a non isomorphic Cayley graph is found, `check_bent_isomorphism` prints
26
the combination `a`, and returns the number of bent functions found so far.
27
Otherwise `check_bent_isomorphism` just returns the total number of
28
bent functions found.
29
30
The optional parameter `certify`, which defaults to `False`, prints
31
the truth table `v` and Cayley graph isomorphism `iso` corresponding
32
to each bent function.
33
"""
34
v = 2 ** dim
35
nbent = 0
36
for a in Combinations(range(1, v), k):
37
t = [1 if x in a else 0 for x in range(v)]
38
f = BooleanFunctionImproved(t)
39
f_is_bent = f.is_bent()
40
if f_is_bent:
41
nbent += 1
42
g = f.cayley_graph()
43
if nbent == 1:
44
g0 = g
45
print(g.is_strongly_regular(parameters=True))
46
if certify:
47
print(t)
48
else:
49
if certify:
50
g_is_iso, iso = g.is_isomorphic(g0, certify=True)
51
else:
52
g_is_iso = g.is_isomorphic(g0)
53
if not g_is_iso:
54
print(a)
55
return nbent
56
elif certify:
57
print(t, iso)
58
return nbent
59
60