-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathabelian_conjectures.sage
executable file
·60 lines (51 loc) · 1.59 KB
/
abelian_conjectures.sage
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env sage
"""Code for Testing Conjectures about Abelian Transducers"""
import itertools
import random
load("binary_invertible_transducer.sage")
def in_edges(T, s):
r = []
for k, ((d0, d1), t) in T.data.items():
if d0 == s or d1 == s:
r.append((k, t))
return r
def monogenic(AA):
T = AA.to_bit()
F, v = T.field_representation()
FF = NumberField(reciprocal_poly(F.polynomial()), 'Z')
OFF = FF.maximal_order()
Z = FF('Z')
basis = Z.powers(AA.m)
if OFF.basis() != basis:
return AA, OFF.basis()
def num_deltas_eq_num_gaps(AA):
T = AA.to_bit()
for Tp in T.terminal_scc_transducers():
if sum(1 for _ in Tp.gaps()) != sum(1 for _ in Tp.deltas()):
return Tp.n
conjecture_tests = [
monogenic,
num_deltas_eq_num_gaps
]
def test_conjectures_for(AA):
for test in conjecture_tests:
result = test(AA)
if result is not None:
print "="*80
print "Counterexample found for " + test.__name__
print AA
print repr(AA)
print "Details:"
print result
print "="*80
def test_conjectures(min_dimension=2, max_dimension=4,
max_size_for=lambda d: 200*d, iterations=1000):
"""
Generates matrices and tests all conjectures.
Prints any counterexamples that appear.
"""
for _ in range(iterations):
dimension = randint(min_dimension, max_dimension)
AA = random_abelian_automaton(dimension, max_size_for(dimension))
print "Testing", AA
test_conjectures_for(AA)