Skip to content

Add sofic.algebra: Krohn-Rhodes theory, holonomy decomposition, and DeDeo (2011) tools - #33

Merged
Autoplectic merged 2 commits into
mainfrom
krohn-rhodes
Oct 25, 2026
Merged

Autoplectic merged 2 commits into
mainfrom
krohn-rhodes

Conversation

@Autoplectic

Copy link
Copy Markdown
Member

Summary

Adds sofic.algebra, a new subpackage for Krohn-Rhodes theory on any deterministic presentation in sofic: DFAs, unifilar automata, unifilar HMMs / ε-machines, and sofic shifts.

Core

  • TransformationSemigroup: enumerated only when needed, a shortest word for every element, a size cap, and a SINK state to complete partial maps.
  • Green's relations, egg boxes, maximal subgroups and Schützenberger groups (as sympy groups), the minimal ideal, and synchronization.
  • syntactic_monoid, is_star_free, and language varieties: piecewise testable, locally testable, definite, group, and commutative languages.
  • holonomy_decomposition (Egri-Nagy & Nehaniv), computed from the generators alone. Its CascadeProduct checks that it emulates the original machine.
  • krohn_rhodes_complexity, returning ComplexityBounds(lower, upper, exact), and prime_decomposition.
  • transition_semigroup() / krohn_rhodes_complexity() on automata, MealyHMM, and SoficShift. New shift invariants factor_syntactic_monoid and factor_krohn_rhodes_complexity. Wheeler-presentation failures now say whether the language is star-free.

DeDeo, "Effective Theories for Circuits and Automata" (Chaos 2011)

  • effective_theory(k) / CascadeProduct.truncate(k): coarse-grained machines on overlapping superstates. This reproduces Fig. 4b, using Fig. 4a rebuilt from the arXiv TeX source.
  • independent_random_maps (Eq. 2), coupled_random_maps (correlated failures), and random_maps: probabilistic automata rewritten as random choices of deterministic maps.
  • element_walk and classify_elements, which reproduce Figs. 5, 6, and 8. In Fig. 8 the walk on A_4 has period 3, so it is uniform only when averaged over a period.
  • walk_information: splits the information lost about the initial state into irreversibility and dissipation. This split is original and uncited.

Other

  • holonomy_information: splits C_mu across the holonomy levels. Original, uncited.
  • projective_semigroup / mixed_state_semigroup: belief-map semigroups of HMMs.

Limitations

  • Complexity lower bound: 0 for aperiodic semigroups, otherwise at least 1. It is raised to k - 1 when the full transformation monoid on k points appears acting on a k-element image set. The full transformation monoid itself is recognized from its generators, without enumerating it. The Rhodes-Tilson chain bounds are not implemented.
  • Nonabelian simple factors are reported by order only.
  • projective_semigroup enumerates up to a cap. When it closes, that proves finiteness; hitting the cap is inconclusive.

Test plan

  • uv run pytest: 2169 passed, 17 skipped
  • New tests in tests/test_algebra_*.py: hypothesis properties (cascade emulation, truncation commutes with every input, Green's classes partition, the information split adds up) and known values (T_n, Z_n, Egri-Nagy & Nehaniv Examples 7.1 and 7.2, DeDeo figures)
  • One-off check: holonomy emulates 300 random semigroups on 6-8 states
  • ruff check, ruff format --check, ty (clean on new code), module doctests
  • Serial Sphinx build with ipython doctests and no warnings (the -j auto build hits an unrelated EOFError)

Ryan James and others added 2 commits October 25, 2026 15:29
Transformation semigroups, Green's relations, syntactic monoids and
star-freeness, the holonomy decomposition as a verifiable cascade product,
Krohn-Rhodes complexity bounds and prime factors, and hooks on automata,
unifilar HMMs / epsilon-machines, and sofic shifts.

Following DeDeo (2011): effective theories from truncated cascades,
random-map representations of probabilistic automata, walks over semigroup
elements, and an irreversibility / dissipation information split. Also
language varieties, minimal ideals and synchronization, Schutzenberger
groups, and belief-map semigroups of HMMs.

Co-authored-by: Cursor <cursoragent@cursor.com>
Compute holonomy group orders and recognize T_n by closing small permutation
groups directly, falling back to sympy only for very large groups. Skip the
tests that need sympy group objects when it is not installed.

Co-authored-by: Cursor <cursoragent@cursor.com>
@Autoplectic
Autoplectic merged commit 6a69d80 into main Oct 25, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant