14
$\begingroup$

It would be nice to collect a list of conditions that imply that a context-free language L is regular, i.e. conditions of the form: "if a given CFG/PDA has property P, then its languages is regular"

The property P does not have to characterize the CFGs generating regular languages. Furthermore, P does not have to be decidable, and P should "somehow depend" on the language being context-free ("the syntactic monoid of L is finite", "L is decidable in space o(log log n)" and so on, are not what I am looking for).

$\endgroup$
5
  • $\begingroup$ seems very likely the general question is undecidable. the analogy is that there are other theorems that "is B actually A" where A is a "smaller" language class than B is undecidable. I recall a question on here wrt maybe CFLs that was similar but cant find it right now. $\endgroup$
    – vzn
    Commented Jun 1, 2012 at 0:49
  • $\begingroup$ by "regularity" you mean, is it really a regular language right? $\endgroup$
    – vzn
    Commented Jun 1, 2012 at 1:16
  • 3
    $\begingroup$ ok found it. this question is very similar to this one, "is a CFG actually a RL" & is known to be undecidable $\endgroup$
    – vzn
    Commented Jun 1, 2012 at 1:21
  • 5
    $\begingroup$ @vzn I think OP is not looking for an algorithm to decide regularity of CFLs but rather for some sufficient conditions. For example, the regularity of a language of a TM is undecidable, but one sufficient condition is that if a language is decidable in $o(n log n)$, then it must be regular. $\endgroup$
    – aelguindy
    Commented Jun 1, 2012 at 8:30
  • $\begingroup$ agreed, distinction is valid. but its also critical to know at same time the general problem is undecidable. "sufficient conditions" are generally closely connected with algorithms eg in the example you gave of o(n lg n) time complexity. $\endgroup$
    – vzn
    Commented Jun 1, 2012 at 15:19

2 Answers 2

16
$\begingroup$
  1. Every unary context-free language is regular. (e.g. a direct consequence of Parikh's theorem)

  2. If every iterative/pumping pair of a context-free language L is degenerated, then L is regular, i.e. L is regular if, for all words x,u,y,v,z it satisfies: $$xu^nyv^nz \in L, \text{for all } n \geq 0 \implies xu^iyv^jz \in L, \text{ for all }i,j \geq 0.$$This was proved by Ehrenfeucht, Rozenberg, "Strong iterative pairs and the regularity of context-free languages", 1983. See "Context-free languages" by Berstel and Boasson for an exposition.

  3. If a context-free language is commutative and linear, then it is regular. (Ehrenfeucht, Haussler, Rozenberg, "On regularity of Context-free Languages", 1983)

$\endgroup$
0
$\begingroup$

Let $M$ be a Monoid and, for any subsets $A, B ⊆ M$ define the left-quotient $$A \backslash B = \{ m ∈ M: (∃a ∈ A) am ∈ B\}.$$ For $m ∈ M$ and $B ⊆ M$, define $m \backslash B = \{m\} \backslash B$. The following identities hold: $$ (A ∪ B) \backslash C = (A \backslash C) ∪ (B \backslash C),\quad (A B) \backslash C = B \backslash (A \backslash C),\quad 1 \backslash A = A, $$ where $A, B, C ⊆ M$ and $1$ denotes the identity of $M$.

For the free monoid $X^*$ generated by a set $X$, and for any $A ⊆ M$, the set $$Q(A) = \{ w \backslash A: w ∈ X^* \}$$ is the state space for the minimal deterministic automaton corresponding to $A$, whose start state is $A$, whose state transitions on $x ∈ X$ from any $B ∈ Q(A)$ are given by $B \overset{x}→ x \backslash B$ and whose final states are those $B ∈ Q(A)$ for which $1 ∈ B$.

It resides in a single state diagram that contains the state diagram of every single automaton over $X$ - both finite and infinite. That, by the way, includes all Turing machines and push-down automata, as well as all oracles for subsets $A ⊆ X^*$ that lie beyond the Chomsky hierarchy. It is the Univeral State Diagram for $X^*$.

The set $Q(A)$ is finite if and only if the minimal deterministic automaton is finite if and only if $A$ is a regular subset of $X^*$.

Example: Consider the subset of $X^*$, given by the grammar $S → u S v$, $S → w$, where $X = \{u, v, w\}$ and denote the subset by $S$. Let $S(n) = S \{v^n\}$ and $T(n) = \{v^n\}$, for $n = 0, 1, 2, ⋯$. Then, $$Q(S) = \{ S(n): n=0,1,2,⋯ \} ∪ \{ T(n): n=0,1,2,⋯ \} ∪ \{∅\},$$ and the following are its state transitions in the Universal State Diagram for $X^*$: $$ S(n) \overset{u}→ S(n+1),\quad S(n) \overset{v}→ ∅,\quad S(n) \overset{w}→ T(n),\\ T(n) \overset{u}→ ∅,\quad T(n+1) \overset{v}→ T(n),\quad T(0) \overset{v}→ ∅,\quad T(n) \overset{w}→ ∅,\\ ∅ \overset{u}→ ∅,\quad ∅ \overset{v}→ ∅,\quad ∅ \overset{w}→ ∅. $$ for $n = 0, 1, 2, ⋯$. The start state is $S = S(0)$ and the sole final state is $T(0)$

Therefore, $S$ is not regular.

The state diagram for the minimal deterministic automaton for $S$ is an infinite ladder with $S$ and $T$ rungs, where $u$ raises the level by one, $w$ crosses over from the $S$ rungs to the $T$ rungs, and $v$ lowers the level by one, and by convention, the $∅$ state is not displayed.

Example: Consider the subset of $X^*$ given by the grammar $S → u S$, $S → S v S$, $S → S w$, $S → x$, where $X = \{u, v, w, x\}$. The grammar specifies the subset that is given as the least fixed-point solution to the following $$S ⊇ \{u\} S ∪ S \{v\} S ∪ S \{w\} ∪ \{x\},$$ or algebraically $S ≥ u S + S v S + S w + x$, where $≥$ denotes the subset ordering relation and $+$ the union operation. The least fixed point solution to $y ≥ f(y)$ is written as $μy·f(y)$.

The one in the previous example could have been written $μs·(u s v + w)$.

In Kleene algebra, the least fixed point solution to $x ≥ a + x b$ is also the least fixed point solution to $x ≥ a b^*$, i.e. $μx·(a + x b) = μx·(a b^*)$. As such, the grammar for this example could just as well be written in EBNF form as $S → (u S | x) (v S | w)^*$, with the corresponding fixed point equation given by $S = μs·(u s + x) (v s + w)^*$.

With that having been said, let $S$ also denote the subset of $X^*$ recognized by the grammar in this example. The least fixed point solution is also a solution to the corresponding equation, i.e. $μx·f(x) = f(μx·f(x))$. Here, that means $$S = (\{u\} S ∪ \{x\}) T,$$ where $$T = (\{v\} S ∪ \{w\})^*,$$ and - since $a b^* b^* = a b^*$ is a Kleene-algebraic identity - it also means that $$S = S T.$$

This is enough to determine that $$Q(S) = \{ S, T, ∅ \},$$ that the state transitions are $$ S \overset{u}→ S,\quad S \overset{v}→ ∅,\quad S \overset{w}→ ∅,\quad S \overset{x}→ T,\\ T \overset{u}→ ∅,\quad T \overset{v}→ S,\quad T \overset{w}→ T,\quad S \overset{x}→ ∅,\\ ∅ \overset{u}→ ∅,\quad ∅ \overset{v}→ ∅,\quad ∅ \overset{w}→ ∅,\quad ∅ \overset{x}→ ∅, $$ that the start state is $S$, that the sole final state is $T$, that $S$ is regular and that it is given by the regular expression $S = u^* x w^* (v u^* x w^*)^*$. Thus, $$μs·(u s + s v s + s w + x) = u^* x w^* (v u^* x w^*)^*.$$

On the other hand, to write the previous example as a regular expression, you would have to add in the following extra symbols $Z = \{b,d,p,q\}$, subjecting them to the identities $$ b d = 1 = p q,\quad b q = 0 = p d,\quad z x = x z\quad (x ∈ X,\quad z ∈ Z), $$ (and, optionally, also to the identity $d b + q p = 1$), in which case you may write $S = b (u p)^* w (q v)^* d$ - i.e. what shall come to be known as a Chomsky-Schützenberger context-free expression, once the new algebraic framework becomes more widely-known.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.