Skip to content

Commit

Permalink
Adding an 3-ary example 'arity_three_order_inf'.
Browse files Browse the repository at this point in the history
Tidying up __init__.py so that 'from thompson import *' will actually be useful.
Can now chain generators.expand()
  • Loading branch information
DMRobertson committed Oct 8, 2014
1 parent 5c45e52 commit 64ae2ff
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 12 deletions.
5 changes: 2 additions & 3 deletions scripts/test_quasinormal.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from test import setup_script
setup_script(__file__)

from thompson.word import Word
from thompson import *
from thompson.examples import *

example_4_5.dump_mapping()
orbit_types(example_4_5, example_4_5.domain)
arity_three_order_inf.dump_mapping()
8 changes: 4 additions & 4 deletions thompson/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
.. moduleauthor:: David Robertson <david.m.robertson1@gmail.com>
"""

from .drawing import Coord, new_drawing
from .permutation import Permutation, random_permutation
from .trees import DrawableTree, random_tree
from .tree_pair import TreePair, random_pair
from .word import Word
from .generators import Generators
from .automorphism import Automorphism, orbit_types
from . import examples

13 changes: 12 additions & 1 deletion thompson/automorphism.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,12 +408,14 @@ def _orbit_type(self, y, basis):
x1 a2: Orbit.incomplete
with respect to the basis [x1 a1, x1 a2]
>>> basis.expand(0)
Generators(2, 1, ['x1 a1 a1', 'x1 a1 a2', 'x1 a2'])
>>> orbit_types(example_4_12, basis)
x1 a1 a1: Orbit.complete_infinite
x1 a1 a2: Orbit.complete_infinite
x1 a2: Orbit.incomplete
with respect to the basis [x1 a1 a1, x1 a1 a2, x1 a2]
>>> basis.expand(2)
Generators(2, 1, ['x1 a1 a1', 'x1 a1 a2', 'x1 a2 a1', 'x1 a2 a2'])
>>> orbit_types(example_4_12, basis)
x1 a1 a1: Orbit.complete_finite
x1 a1 a2: Orbit.complete_finite
Expand Down Expand Up @@ -492,7 +494,16 @@ def _test_semi_infinite(self, y, basis, backward=False):
#TODO the named elements A, B, C, X_n of Thompson's V.

def orbit_types(aut, basis=None, words=None):
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`"""
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`.
>>> orbit_types(arity_three_order_inf)
x1 a1: Orbit.left_semi_infinite
x1 a2: Orbit.complete_infinite
x1 a3 a1: Orbit.complete_infinite
x1 a3 a2: Orbit.complete_infinite
x1 a3 a3: Orbit.right_semi_infinite
with respect to the basis [x1 a1, x1 a2, x1 a3 a1, x1 a3 a2, x1 a3 a3]
"""
if basis is None:
basis = aut._minimal_expansion()
if words is None:
Expand Down
10 changes: 8 additions & 2 deletions thompson/examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from .automorphism import Automorphism
from .generators import Generators

__all__ = ["cyclic_order_six",
__all__ = ["cyclic_order_six", "arity_three_order_inf",
"example_4_5", "example_4_11", "example_4_12", "example_4_25"]

#Example 4.5
Expand Down Expand Up @@ -34,4 +34,10 @@
leaves = ["x a1 a1", "x a1 a2 a1", "x a1 a2 a2 a1", "x a1 a2 a2 a2", "x a2 a1", "x a2 a2"]
domain = Generators(2, 1, leaves)
range = Generators(2, 1, [leaves[0], leaves[3], leaves[4], leaves[5], leaves[2], leaves[1]])
cyclic_order_six = Automorphism(2, 1, domain, range)
cyclic_order_six = Automorphism(2, 1, domain, range)

#An example with arity n=3.
d = Generators.standard_basis(3, 1).expand(0).expand(2).expand(0)
r = Generators.standard_basis(3, 1).expand(0).expand(2).expand(4)
r[-3:] = reversed(r[-3:])
arity_three_order_inf = Automorphism(3, 1, d, r)
5 changes: 3 additions & 2 deletions thompson/generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,13 @@ def expand(self, index):
>>> g = Generators.standard_basis(3, 1); g
Generators(3, 1, ['x1'])
>>> g.expand(0); g
>>> g.expand(0)
Generators(3, 1, ['x1 a1', 'x1 a2', 'x1 a3'])
>>> g.expand(1); g
>>> g.expand(1)
Generators(3, 1, ['x1 a1', 'x1 a2 a1', 'x1 a2 a2', 'x1 a2 a3', 'x1 a3'])
:raises IndexError: if there is no generator at index *index*.
"""
self[index: index+1] = [self[index].alpha(i) for i in range(1, self.arity+1)]
return self #allows chaining

0 comments on commit 64ae2ff

Please sign in to comment.