L-graphs and what they represent in TOC
Last Updated :
11 Jul, 2025
In Theory of Computation (TOC), Finite Automata (DFA/NFA) are mathematical models used to recognize Regular Languages. However, not all programming languages can be represented using Finite Automata because they require more computational power than what FA can provide. Languages like C, Pascal, Haskell, and C++ follow specific structures and grammars that can be depicted using simple graphs. Most of these graphs are either Non-deterministic Finite Automata (NFA) or Deterministic Finite Automata (DFA). However, NFA and DFA determine only the simplest group of languages—regular languages—according to Chomsky hierarchy.
This raises the question: what about other types of languages? One of the answers is the Turing Machine, but Turing machines are difficult to visualize. This is where L-graphs come into play.
L-graphs extend finite automata concepts to represent context-sensitive languages. To understand L-graphs better, let’s examine an example of a language that cannot be represented by DFAs, NFAs, or PDAs.
Example Language
The language: L = \{ a^n b^n c^n \mid n \geq 1 \} can be represented using an L-graph but not by simpler finite automata. Corresponding L-graph looks like this:

Structure of L-Graphs
An L-graph possesses two key features:
- Bracket Groups: L-graphs have up to two independent bracket groups that do not depend on input symbols.
- Dyck Language Compliance: Both bracket groups must form a valid string from a Dyck language for the input string to be accepted.
Essentially, an L-graph is a modified finite automaton with added bracket groups.
How L-Graphs Accept Strings
Consider the following transitions:
- abc:
\{\varepsilon, \varepsilon, \varepsilon\} \rightarrow \{a, (, \varepsilon\} \rightarrow \{ab, (), <\} \rightarrow \{abc, (), <>\}
- a²b²c²:
\{\varepsilon, \varepsilon, \varepsilon\} \rightarrow \{a, (, \varepsilon\} \rightarrow \{aa, ((, \varepsilon\} \rightarrow \{aab, ((), <\} \rightarrow \{aabb, (()), <<\} \rightarrow \{aabbc, (()), <<>\} \rightarrow \{aabbcc, (()), <<>>\}
- a⁵b⁵c⁵:
\{\varepsilon, \varepsilon, \varepsilon\} \rightarrow \{a, (, \varepsilon\} \rightarrow \dots \rightarrow \{aaaaa, (((((, \varepsilon\} \rightarrow \{aaaaab, (((((), <\} \rightarrow \dots \rightarrow \{aaaaabbbbb, ((((())))), <<<<<\} \rightarrow \{aaaaabbbbbc, ((((())))), <<<<<>\} \rightarrow \dots \rightarrow \{aaaaabbbbbccccc, ((((())))), <<<<<>>>>>\}
1. Neutral Path
A path in the L-graph is called neutral if both bracket strings are right-balanced.
2. Nest
If a neutral path T can be represented as: T = T1T2T3 where T1 and T3 are cycles and T2 is a neutral path, then T is called a nest.
3. (ω, d)-Core
A (ω, d)-core in an L-graph G, defined as Core(G, ω, D), is a set of (ω, d)-canons.
A (ω, d)-canon is a path that contains at most:
- m <= ω neutral cycles
- k <= d nests
where each path segment follows: T_{1_1} \dots T_{1_k} T_{2_1} T_{3_1} \dots T_{3_k}
4. Context-Free L-Graph
An L-graph is context-free if it has only one bracket group. All rules in the L-graph follow one of the two structures:
-
['symbol' \mid 'bracket', ?]
-
['symbol' \mid ?, 'bracket']
Dyck Language Definition
A Dyck language consists of two disjoint alphabets, \Sigma_{(} \text{ and } \Sigma_{)}. There exists a bijection: \phi: \Sigma_{(} \rightarrow \Sigma_{)} where the language is defined by the grammar: S \rightarrow \varepsilon \mid aSbS, a \in \Sigma_{(}, b = \phi(a)
Real-Life Example: Organizational Structure
A real-life application of L-graphs can be seen in hierarchical structures such as XML parsing and dependency graphs.
Scenario:
- The main graph represents the company’s departments (Sales, Marketing, Finance, HR, etc.).
- The L-graph represents managerial relationships, where each vertex is a manager and edges show supervisory relationships.
This representation helps in understanding:
- Chain of command
- Decision-making processes
Explore
Automata _ Introduction
Regular Expression and Finite Automata
CFG
PDA (Pushdown Automata)
Introduction of Pushdown Automata
5 min read
Pushdown Automata Acceptance by Final State
4 min read
Construct Pushdown Automata for given languages
4 min read
Construct Pushdown Automata for all length palindrome
6 min read
Detailed Study of PushDown Automata
3 min read
NPDA for accepting the language L = {anbm cn | m,n>=1}
2 min read
NPDA for accepting the language L = {an bn cm | m,n>=1}
2 min read
NPDA for accepting the language L = {anbn | n>=1}
2 min read
NPDA for accepting the language L = {amb2m| m>=1}
2 min read
NPDA for accepting the language L = {am bn cp dq | m+n=p+q ; m,n,p,q>=1}
2 min read
Construct Pushdown automata for L = {0n1m2m3n | m,n ⥠0}
3 min read
Construct Pushdown automata for L = {0n1m2n+m | m, n ⥠0}
2 min read
NPDA for accepting the language L = {ambncm+n | m,n ⥠1}
2 min read
NPDA for accepting the language L = {amb(m+n)cn| m,n ⥠1}
3 min read
NPDA for accepting the language L = {a2mb3m|m>=1}
2 min read
NPDA for accepting the language L = {amb2m+1 | m ⥠1}
2 min read
NPDA for accepting the language L = {aibjckdl | i==k or j==l,i>=1,j>=1}
3 min read
Construct Pushdown automata for L = {a2mc4ndnbm | m,n ⥠0}
3 min read
NPDA for L = {0i1j2k | i==j or j==k ; i , j , k >= 1}
2 min read
NPDA for accepting the language L = {anb2n| n>=1} U {anbn| n>=1}
2 min read
NPDA for the language L ={wÐ{a,b}* | w contains equal no. of a's and b's}
3 min read
Turing Machine
Decidability
TOC Interview preparation
TOC Quiz and PYQ's in TOC