Wolfram Language Paclet Repository

Community-contributed installable additions to the Wolfram Language

Primary Navigation

    • Cloud & Deployment
    • Core Language & Structure
    • Data Manipulation & Analysis
    • Engineering Data & Computation
    • External Interfaces & Connections
    • Financial Data & Computation
    • Geographic Data & Computation
    • Geometry
    • Graphs & Networks
    • Higher Mathematical Computation
    • Images
    • Knowledge Representation & Natural Language
    • Machine Learning
    • Notebook Documents & Presentation
    • Scientific and Medical Data & Computation
    • Social, Cultural & Linguistic Data
    • Strings & Text
    • Symbolic & Numeric Computation
    • System Operation & Setup
    • Time-Related Computation
    • User Interface Construction
    • Visualization & Graphics
    • Random Paclet
    • Alphabetical List
  • Using Paclets
    • Get Started
    • Download Definition Notebook
  • Learn More about Wolfram Language

Automata

Guides

  • Automata

Tech Notes

  • Automata Package

Symbols

  • AlphabetBaseCount
  • AlphabetCountCA
  • AlphabetCount
  • AlphabetList
  • AlphabetProfile
  • AlphabetTrackCount
  • AlphabetTraitQ
  • Alpha
  • AlphaQ
  • AnalyzeOrbit
  • ApplyTransduction
  • AssignFunction
  • AssignHomomorphismDFA
  • AssignTransduction
  • AssignTransitionFunction
  • AutomataDefaults
  • BalancedQCA
  • BEFA
  • BEFAToFA
  • BooleanTransitionMatrix
  • Bound
  • CA
  • CanonicalFA
  • CartesianProduct
  • CirculantFA
  • ClassifyCA
  • CloneFA
  • Closure
  • ClosureSearch
  • ComplementFA
  • CompletePDFA
  • ComposeCA
  • ComputationFA
  • ComputationGraphFA
  • ConcatenateFA
  • Concatenate
  • CondensationGraph
  • ConvertToCA
  • CoverQDFA
  • CycleDecomposition
  • CycleShape
  • DCLDimension
  • DCLGreenToGrid
  • DCL
  • DCLUnpack
  • DeterministicQ
  • DeterminizeFA
  • DFAQ
  • DivisibilityDFA
  • DomainFunction
  • DomCodomCA
  • DoTrace
  • ECA
  • EmptyFA
  • EpsFromEmpty
  • EpsilonEliminationFA
  • EpsilonFA
  • EpsilonFreeQ
  • Eps
  • EpsQ
  • EpsToEmpty
  • EquivalentQFA
  • Existential
  • FA
  • FATraitQ
  • Fill
  • FinalStateList
  • FindRepetitions
  • FiniteLanguageFA
  • FlattenOne
  • FormatEdgesGraph
  • FormatEps
  • FormatVerticesGraph
  • Frequencies
  • FromBitVector
  • FromKernelImageSGT
  • FrontierFromDFA
  • FrontierRW
  • FrontierToDFA
  • FSMQ
  • GatherTransitions
  • GenerateFA
  • GetColorList
  • GetTraits
  • GlobalMapCA
  • GraphPaths
  • GridOffset
  • GrowthFunctionDFA
  • HideGraph
  • IdempotentQSGT
  • IdentitySGT
  • ImageSGT
  • IndexedFAQ
  • IndexFA
  • Index
  • InitialStateList
  • InitialState
  • IntersectionFA
  • InverseCA
  • IsomorphicQDFA
  • KernelImageSelectorQ
  • KernelImageSGT
  • KernelSGT
  • KleeneStarFA
  • LabelList
  • LanguageFactorFA
  • LanguageFA
  • ListShuffle
  • LocalMapCA
  • MatrixToTransitions
  • MinimizeDFA
  • MinimizeFA
  • Monoid
  • NNFA
  • NNFAToFA
  • NonDecreasingSequences
  • NonTrivialComponentQ
  • OrbitCA
  • PadicOrder
  • PadicValuation
  • Pairs
  • ParikhVector
  • ParseRange
  • Partitions
  • PDFAQ
  • PermutationToTransformation
  • PermuteFA
  • PlotFA
  • PlotFunction
  • PlotGrid
  • PlotMatrix
  • PlotRelation
  • PositionFA
  • PositionList
  • PositionOne
  • PowerSet
  • PowerSGT
  • PrintCA
  • ProductFA
  • ProductGraph
  • ProductTransitionSystem
  • PropertyQFA
  • RandomSGT
  • RankCartesian
  • RankingRules
  • RankSGT
  • RegexAlphabet
  • RegexEmptyQ
  • RegexEpsQ
  • RegexToBEFA
  • RegexToDetRegex
  • RegexToFA
  • RegexToGlushkov
  • RegexToNNFA
  • RelationToMatrix
  • REP
  • RES
  • RET
  • ReverseFA
  • RewritePrint
  • RewriteRulesSimplify
  • RewriteString
  • RewriteToIrreducible
  • RuleCA
  • RulesToTransitions
  • SeedConfiguration
  • SelectOptions
  • SemigroupCayleyGraph
  • SemigroupCayleyTable
  • SemigroupDegree
  • SemigroupElements
  • SemigroupEquations
  • SemigroupGenerate
  • SemigroupGenerators
  • Semigroup
  • SemigroupOrder
  • SemigroupQ
  • SemigroupToMonoid
  • SemigroupWitnesses
  • SemilinearDFA
  • SetAlphabet
  • SetFinal
  • SetInitialFinal
  • SetInitial
  • SetStates
  • SetTraits
  • SetTransitions
  • SGT
  • SGTraitQ
  • ShiftOrbit
  • ShowGraph
  • ShowGrid
  • ShrinkCA
  • ShuffleProductFA
  • SizeOnly
  • StateCount
  • StateDelete
  • StateList
  • StateType
  • StringifyList
  • StronglyConnectedComponents
  • SubAutomatonFA
  • SubTransitionSystem
  • SymbolList
  • TDGraph
  • TDGSelectAll
  • TDQ
  • ToBitVector
  • ToClasses
  • ToFredkinCA
  • ToIndex
  • ToKernelFA
  • ToKernel
  • ToSemiautomatonCA
  • ToWelchAutomatonCA
  • ToWidthTwoCA
  • ToWord
  • TransformationDFA
  • TransformationList
  • TransformationListQ
  • TransformationProduct
  • TransformationReplace
  • TransientMod
  • TransitionAdd
  • TransitionCosupport
  • TransitionCount
  • TransitionDelete
  • TransitionFunctionList
  • TransitionLabel
  • TransitionList
  • TransitionMatrix
  • TransitionsMap
  • TransitionSource
  • TransitionsReverse
  • TransitionsSelect
  • TransitionsSort
  • TransitionStates
  • TransitionsToBlocks
  • TransitionSupport
  • TransitionSystemAlphabet
  • TransitionSystemGraph
  • TransitionSystem
  • TransitionTarget
  • TransitionType
  • TransListQ
  • TrapStateList
  • TrimFA
  • TrimStateList
  • TSys
  • TSysQ
  • TSysTraitQ
  • Tupeln
  • Type
  • UnBoole
  • UnionFA
  • UniversalFA
  • UnrankCartesian
  • WidthCA
  • WordBinomial
  • WordFactorFA
  • WordLength
  • WordOrder
  • WordQ
  • WordRandom
  • WordShuffle
  • Words
  • WordSort
  • $AutomataDate
  • $AutomataVersion
  • $defaultPlotEmpty
  • $defaultPlotEpsilon
  • $defaultPlotStar
  • $defaultPlotUniversal
Automata Package
Finite State Machines
Cellular Automata
Syntactic Semigroups
​
Automata supports computation with finite state machines, syntactic semigroups and one-dimensional cellular automata. There are some 250 functions in the package, we only mention a few of them below. For more information and more examples, see
CDM
.
Finite State Machines

Formatting

By default, formatting of finite automata is turned off. In particular for large automata it is usually preferable to turn formatting on.
In[7]:=
Needs["KlausSutner`Automata`"]
In[46]:=
M=
PositionFA
"a",-3,
Alpha
[2]
Out[46]=
FATSys4,2,
,Alpha[2,],TransTypeNFA,AccCondExistential[{1},{4}]
In[47]:=
FormatFA[]​​M
Out[48]=
FA
type: NFA
states: 4
alphabet: 2

In[49]:=
M//
PlotFA
Out[49]=
The situation for semigroups is similar.
In[50]:=
MM=
DeterminizeFA
[M]
Out[50]=
FA
type: DFA
states: 8
alphabet: 2

In[53]:=
sg=
SemigroupGenerate

SemigroupGenerators
[MM]
Out[53]=
Semigroup[{SGT[{2,3,5,7,5,7,3,2}],SGT[{1,4,6,8,6,8,4,1}],SGT[{3,5,5,3,5,3,5,3}],SGT[{4,6,6,4,6,4,6,4}],SGT[{2,7,7,2,7,2,7,2}],SGT[{1,8,8,1,8,1,8,1}],SGT[{5,5,5,5,5,5,5,5}],SGT[{6,6,6,6,6,6,6,6}],SGT[{7,7,7,7,7,7,7,7}],SGT[{8,8,8,8,8,8,8,8}],SGT[{3,3,3,3,3,3,3,3}],SGT[{4,4,4,4,4,4,4,4}],SGT[{2,2,2,2,2,2,2,2}],SGT[{1,1,1,1,1,1,1,1}]},Generators{SGT[{2,3,5,7,5,7,3,2}],SGT[{1,4,6,8,6,8,4,1}]},Witnesses{a,b,aa,ab,ba,bb,aaa,aab,aba,abb,baa,bab,bba,bbb},Equations{aaaaaaa,aaabaab,aabaaba,aabbabb,abaabaa,ababbab,abbabba,abbbbbb,baaaaaa,baabaab,babaaba,babbabb,bbaabaa,bbabbab,bbbabba,bbbbbbb}]
In[54]:=
FormatSemigroup[]
In[55]:=
sg
Out[55]=
Semigroup
order: 14
degree: 8

Lastly, there is the problem of making the empty string visible. Automata uses a alternative symbol Eps for the empty string. To make this look better, one can format Eps.
In[61]:=
Words
2,
Alpha
[2]
Out[61]=
{Eps,a,b,aa,ab,ba,bb}
In[62]:=
FormatEps
[]
In[64]:=
Words
2,
Alpha
[2]​​%//
WordLength
Out[64]=
{ϵ,a,b,aa,ab,ba,bb}
Out[65]=
{0,1,1,2,2,2,2}
Formatting Eps may cause problems when the input to certain function involves Eps. For extensive computations it is best to turn ϵ-formatting off.
FormatEps
[False]

Machine Constructions

Define a 2-letter alphabet for use in various machine constructions below.
In[9]:=
A2=
Alpha
[2];​​Through
AlphabetList
,
AlphabetCount
[A2]
Out[10]=
{{a,b},2}
We construct a partial DFA (deterministic but incomplete) accepting a finite language using a quotient construction.
In[194]:=
pdfa=
FiniteLanguageFA
[{"aaa","bbb","aabb"},A2]
Out[194]=
FA
type: PDFA
states: 9
alphabet: 2

Sampling the language of the automaton shows that the machine works as expected.
In[195]:=
LanguageFA
pdfa,12,
SizeOnly
True​​
LanguageFA
[pdfa,10]
Out[195]=
{0,0,0,2,1,0,0,0,0,0,0,0,0}
Out[196]=
{{},{},{},{aaa,bbb},{aabb},{},{},{},{},{},{}}
We can visualize the machine as a edge-labeled directed graph.
In[208]:=
PlotFA
[pdfa]
Out[208]=
For small alphabets, it is often preferable to use colors instead of edge labels.
In[197]:=
PlotFA
pdfa,
Type
"MultiColor",EdgeStyleThick,VertexSizeMedium
Out[197]=
For a PDFA, determinization simply adds a sink. In this case, we obtain a non-minimal DFA.
In[203]:=
dfa=
DeterminizeFA
[pdfa]
Out[203]=
FA
type: DFA
states: 10
alphabet: 2

By default, the plotting function displays only the trim part of the automaton.
Minimization collapses some of the states and produces a DFA of size 7.
The machines are all equivalent (the equivalence test does not use minimization).
The construction of the PDFA is based on a simple trie, alternatively we can use a quotient construction (which is inefficient for large sets of words).
The quotient construction ensures that the automaton is already minimal.
The machine works as advertised for words of length 6:
Here are two mod-counters for plain factors and their intersection.
The constructor for semilinear machines generally produces non-minimal machines, as a result our counter is larger than needed.
It is often useful to preserve state sets during certain operations.Minimization produces a new automaton whose states are naturally sets of states of the old automaton.
Thus, the states 1, 7, 8 are behaviorally equivalent in sl12.
Another operation where structured state sets are often useful is determinization, based on the standard Rabin-Scott construction.
On occasion, one may want to preserves states several levels deep. Here is de Bruijn type DFA with a naturally structured state set: the states are all words up to length 4.
Preserving state sets under minimization can be helpful to understand the structure of a machine.
One can directly see how behaviorally equivalent states are collected.
In this case, converting back produces the original automaton.
By insisting that the back transitions lead to the same branch, rather than just nodes constructed earlier in the process, we get a larger frontier automaton.
The picture obscures the tree structure, but it can be recovered as follows.
The machines are duly equivalent.

Regular Expressions

A regular expression for the language "even number of a, even number of b".
The default conversion in general produces a machine with ϵ-transitions.
Eliminating the ϵ-transitions adds a few more letter-transitions.
Determinization yields a machine on 8 states.
Lastly, the minimal automaton.
Another example, a regular expression that recognizes numbers that are divisible by 3, written in binary, MSD first, with leading zeros. It is convenient to switch the default alphabet for regular expressions to the corresponding digit alphabet.
Our presentation allows for leading zeros.
Check the corresponding numerical values
All the machines that appear during the conversion process.
The growth function is easy to find in this case.
Syntactic Semigroups
The corresponding semigroup has 14 elements and is of degree 8, the state complexity of M.
The Cayley table of this semigroup.
The resulting data structure also maintains information about witnesses and equations.
A table of semigroup elements with various special properties.
The witnesses for the right nulls are all words of length 3.
The equations remove the first letter of all length 4 words, so this is consistent.

Transformation DFA

The transformation semigroup of a DFA can be turned into another DFA whose states are the elements of the semigroup. The new automaton is potentially much larger and covers the original machine. First, an example with modest increase in size.
A 3-state DFA can generate the full transformations semigroup of degree 3,
Cellular Automata

De Bruijn Automaton

Two orbits of elementary cellular automaton number 45, on a two-point seed and on a random configuration.
Surjectiveness on infinite configurations implies surjectiveness on infinitely many finite configurations by a compactness argument (using cyclic boundary conditions). The corresponding de Bruijn automaton is unambiguous.
We can find all ECA with surjective global map by checking universality of these de Bruijn automata (but beware exponential blowup for cellular automata of larger width).
So there are 2 limit cycle of length 24, 3 of length 6, and so on.

Fischer Automata

Since this language is always factorial, extensible and transitive, there is a better minimal automaton for this language, obtained as follows.
The minimal DFA here has maximal size 16.
A deterministic and reduced semiautomaton for the cover language can be determined by finding a terminal strongly connected component in the minimal DFA for the language (which component is uniquely determined). Here is a function that computes this minimal Fischer automaton.
The minimal Fischer automaton for ECA 210 looks like so.
It has only one strongly connected component.

© 2025 Wolfram. All rights reserved.

  • Legal & Privacy Policy
  • Contact Us
  • WolframAlpha.com
  • WolframCloud.com