Skip to content

Commit 64ae2ff

Browse files
committed
Adding an 3-ary example 'arity_three_order_inf'.
Tidying up __init__.py so that 'from thompson import *' will actually be useful. Can now chain generators.expand()
1 parent 5c45e52 commit 64ae2ff

File tree

5 files changed

+29
-12
lines changed

5 files changed

+29
-12
lines changed

scripts/test_quasinormal.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
from test import setup_script
22
setup_script(__file__)
33

4-
from thompson.word import Word
4+
from thompson import *
55
from thompson.examples import *
66

7-
example_4_5.dump_mapping()
8-
orbit_types(example_4_5, example_4_5.domain)
7+
arity_three_order_inf.dump_mapping()

thompson/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
.. moduleauthor:: David Robertson <david.m.robertson1@gmail.com>
44
"""
55

6-
from .drawing import Coord, new_drawing
7-
from .permutation import Permutation, random_permutation
8-
from .trees import DrawableTree, random_tree
9-
from .tree_pair import TreePair, random_pair
6+
from .word import Word
7+
from .generators import Generators
8+
from .automorphism import Automorphism, orbit_types
9+
from . import examples
1010

thompson/automorphism.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,12 +408,14 @@ def _orbit_type(self, y, basis):
408408
x1 a2: Orbit.incomplete
409409
with respect to the basis [x1 a1, x1 a2]
410410
>>> basis.expand(0)
411+
Generators(2, 1, ['x1 a1 a1', 'x1 a1 a2', 'x1 a2'])
411412
>>> orbit_types(example_4_12, basis)
412413
x1 a1 a1: Orbit.complete_infinite
413414
x1 a1 a2: Orbit.complete_infinite
414415
x1 a2: Orbit.incomplete
415416
with respect to the basis [x1 a1 a1, x1 a1 a2, x1 a2]
416417
>>> basis.expand(2)
418+
Generators(2, 1, ['x1 a1 a1', 'x1 a1 a2', 'x1 a2 a1', 'x1 a2 a2'])
417419
>>> orbit_types(example_4_12, basis)
418420
x1 a1 a1: Orbit.complete_finite
419421
x1 a1 a2: Orbit.complete_finite
@@ -492,7 +494,16 @@ def _test_semi_infinite(self, y, basis, backward=False):
492494
#TODO the named elements A, B, C, X_n of Thompson's V.
493495

494496
def orbit_types(aut, basis=None, words=None):
495-
r"""Prints the classification of the orbits under *aut* of each word in *words* with respect to *basis*. If *basis* is omitted, it is taken to be the minimal expansion given by :meth:`~thompson.automorphism._minimal_expansion`. If *words* is omited, it is taken to be the same as *basis*. See the docstring for :meth:`~thompson.automorphism._orbit_type`"""
497+
r"""Prints the classification of the orbits under *aut* of each word in *words* with respect to *basis*. If *basis* is omitted, it is taken to be the minimal expansion given by :meth:`~thompson.automorphism._minimal_expansion`. If *words* is omited, it is taken to be the same as *basis*. See the docstring for :meth:`~thompson.automorphism._orbit_type`.
498+
499+
>>> orbit_types(arity_three_order_inf)
500+
x1 a1: Orbit.left_semi_infinite
501+
x1 a2: Orbit.complete_infinite
502+
x1 a3 a1: Orbit.complete_infinite
503+
x1 a3 a2: Orbit.complete_infinite
504+
x1 a3 a3: Orbit.right_semi_infinite
505+
with respect to the basis [x1 a1, x1 a2, x1 a3 a1, x1 a3 a2, x1 a3 a3]
506+
"""
496507
if basis is None:
497508
basis = aut._minimal_expansion()
498509
if words is None:

thompson/examples.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from .automorphism import Automorphism
44
from .generators import Generators
55

6-
__all__ = ["cyclic_order_six",
6+
__all__ = ["cyclic_order_six", "arity_three_order_inf",
77
"example_4_5", "example_4_11", "example_4_12", "example_4_25"]
88

99
#Example 4.5
@@ -34,4 +34,10 @@
3434
leaves = ["x a1 a1", "x a1 a2 a1", "x a1 a2 a2 a1", "x a1 a2 a2 a2", "x a2 a1", "x a2 a2"]
3535
domain = Generators(2, 1, leaves)
3636
range = Generators(2, 1, [leaves[0], leaves[3], leaves[4], leaves[5], leaves[2], leaves[1]])
37-
cyclic_order_six = Automorphism(2, 1, domain, range)
37+
cyclic_order_six = Automorphism(2, 1, domain, range)
38+
39+
#An example with arity n=3.
40+
d = Generators.standard_basis(3, 1).expand(0).expand(2).expand(0)
41+
r = Generators.standard_basis(3, 1).expand(0).expand(2).expand(4)
42+
r[-3:] = reversed(r[-3:])
43+
arity_three_order_inf = Automorphism(3, 1, d, r)

thompson/generators.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,12 +167,13 @@ def expand(self, index):
167167
168168
>>> g = Generators.standard_basis(3, 1); g
169169
Generators(3, 1, ['x1'])
170-
>>> g.expand(0); g
170+
>>> g.expand(0)
171171
Generators(3, 1, ['x1 a1', 'x1 a2', 'x1 a3'])
172-
>>> g.expand(1); g
172+
>>> g.expand(1)
173173
Generators(3, 1, ['x1 a1', 'x1 a2 a1', 'x1 a2 a2', 'x1 a2 a3', 'x1 a3'])
174174
175175
:raises IndexError: if there is no generator at index *index*.
176176
"""
177177
self[index: index+1] = [self[index].alpha(i) for i in range(1, self.arity+1)]
178+
return self #allows chaining
178179

0 commit comments

Comments
 (0)