Computability and Complexity/Formal Languages/Other Language Classes/Counting Languages

= Counting Languages =

Definition
The set of counting languages is the set of languages that can be generated by a counter automaton, a deterministic finite automaton (DFA) (see Regular Languages) with a finite number of infinite counters. These counters can be incremented or decremented during state transitions, and their statuses can be used to determine transitions.

Position in the Hierarchy of Language Classes
If the counters are unused, a counter automaton is equivalent to a DFA, so the regular languages are a subset of the counting languages. There are also context free languages that are counting languages (such as {anbn | n ≥ 0}), context-free languages that are not counting languages (Chomsky says so but never gives an example), and context-sensitive (but not context-free) languages that are counting languages (such as {anbmanbmccc | n,m ≥ 0}). A linear bounded automaton (see Context Sensitive Languages) can emulate a counter automaton by assuming that the counters cannot reach values greater than the length of the input string, and thus can store the counter information in an amount of space linearly based on the size of the input string. The rest of the CA is essentially a DFA, which LBAs can also emulate in linear space. Linear space plus linear space is still linear, so the counting languages are a subset of the context-sensitive languages, and intersect but are not nested with the context-free languages.

Example
The code below is a sample CA emulator in Perl. Given the description of a machine and an input string, it simulates the machine processing the input string, and shows whether the machine accepts or not.

The syntax is: progname.pl CAFile inputFile, where CAFile is a text file containing the CA instructions, and inputFile is a text file containing the input string. Some sample inputs, including a set of CA instructions for a machine to recognize $$\{a^{n}b^{m}a^{n}b^{m}ccc|n,m \ge 0\}$$, can be found under ../sample CA inputs/.

Previous | Next