The Wayback Machine - https://web.archive.org/web/20241009145258/https://www.geeksforgeeks.org/l-graphs-and-what-they-represent-in-toc/
Open In App

L-graphs and what they represent in TOC

Last Updated : 07 Feb, 2023
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

Prerequisite – Finite automata introduction All programming languages can be represented as a finite automata. C, Paskal, Haskell, C++, all of them have a specific structure, grammar, that can be represented by a simple graph. Most of the graphs are NFA’s or DFA’s. But NFA’s and DFA’s determine the simplest possible language group: group of regular languages [Chomsky’s hierarchy]. This leaves us with a question: what about all other types of languages? One of the answers is Turing machine, but a Turing machine is hard to visualize. This is why in this article I will tell you about a type of finite automata called an L-graph. In order to understand how L-graphs work we need to know what type of languages L-graphs determine. To put it simply, L-graphs represent context-sensitive type of languages [and every other type that the context-sensitive group contains]. If you don’t know what “context-sensitive” means, let me show you an example of a language that can be represented by an L-graph and not by any easier type of finite automata. This language is L = \{ a^nb^nc^n | n \geqslant 1 \} . Corresponding L-graph looks like this: As you can see the brackets after the symbol ‘|’ control the numbers of symbols that come after the symbols ‘a’. This leads us to the two features that all L-graphs possess: all L-graphs have up to two independent from each other and from input symbols bracket groups, both bracket groups have to be right [string from a Dyck language] in order for the string of input symbols to be accepted by the given L-graph. You can see that an L-graph is just a version of finite automata with an added couple of bracket groups. To help you get an understanding of why the languages determined by L-graphs are context-sensitive, check what strings the L-graph shown above has to accept. abc: \{\varepsilon, \varepsilon, \varepsilon\} \rightarrow \{a, (, \varepsilon} \rightarrow \{ab, (), <\} \rightarrow \{abc, (), <>\}\\* a^2b^2c^2: \{\varepsilon, \varepsilon, \varepsilon\} \rightarrow \{a, (, \varepsilon\} \rightarrow \{aa, ((, \varepsilon\} \rightarrow \{aab, ((), <\} \rightarrow \{aabb, (()), <<\} \rightarrow \{aabbc, (()), <<>\} \rightarrow \{aabbcc, (()), <<>>\}\\* a^5b^5c^5: \{\varepsilon, \varepsilon, \varepsilon\} \rightarrow \{a, (, \varepsilon\} \rightarrow \ldots \rightarrow \{aaaaa, (((((, \varepsilon\} \rightarrow \{aaaaab, (((((), <\} \rightarrow \ldots \rightarrow \{aaaaabbbbb, ((((())))), <<<<<\} \rightarrow \{aaaaabbbbbc, ((((())))), <<<<<>\} \rightarrow \ldots \rightarrow \{aaaaabbbbbccccc, ((((())))), <<<<<>>>>>\} To conclude, I would like to add three other definitions that I’ll be using in the future. These definitions are very important for the hypothesis [and its future proof or disproof]. Refer – Hypothesis (language regularity) and algorithm (L-graph to NFA) We will call a path in the L-graph neutral, if both bracket strings are right. If a neutral path T can be represented like this, T = T_1T_2T_3 , where T_1 and T_3 are cycles and T_2 is a neutral path (T_1 , T_2 or T_3 can be empty), T is called a nest. We can also say that the three (T_1 , T_2 , T_3 ) is a nest or that T_1 and T_3 form a nest in the path T. (\omega , d)-core in an L-graph G, defined as Core(G, \omega , d), is a set of (\omega , d)-canons. (\omega , d)-canon, where \omega and d are positive whole numbers, is a path that contains at most m, m \leqslant \omega , neutral cycles and at most k, k k \leqslant d d, nests that can be represented this way: T_1_1...T_1_kT_2_1T_3_1...T_3_k is part of the path T, T_i_l , i = 1 or 3, 1 \leqslant l \leqslant k , are cycles, every path T_1_jT_2_jT_3_j is a nest, where T_2_j = T_1_(_j_-_1_)T_2_(_j_-_1_)T_3_(_j_-_1_) , 2 \leqslant j \leqslant k-1 . The last definition is about a context free L-graph. An L-graph G is called context free if G has only one bracket group (all rules in the L-graph have only one look of these two: [‘symbol’ | ‘bracket’, ?] or [‘symbol’ | ?, ‘bracket’]). [Definition of a Dyck language. \Sigma_( and \Sigma_) are disjoint alphabets. There exists a bijection (function that for every element from the 1st set matches one and only one element from the 2nd set) \phi: \Sigma_( \rightarrow \Sigma_) . Then the language defined by the grammar S \rightarrow \varepsilon | aSbS , a \in \Sigma_(, b = \phi(a) , we will call a Dyck language.]

Example

A real-life example of using L-graphs could be in the context of a company’s organizational structure.

Imagine a company with different departments (sales, marketing, finance, HR, etc.) and each department has different sub-departments. We can represent this organizational structure as a graph where each vertex represents a department and the edges represent the relationships between them (i.e, which department is a sub-department of another).

Now, let’s say we want to represent the relationships between the managers of each department. We can create an L-graph, where each vertex represents a manager and the edges represent the relationships between them (i.e, which manager is the supervisor of another).

In this scenario, the original graph represents the overall structure of the company, while the L-graph represents the relationship between the managers. This can be useful for understanding the chain of command and decision-making processes within the company.

It’s worth to mention that this is a simple example and in real life scenarios L-graphs can be used to represent much more complex systems and relations and these graphs are used in various fields such as computer science, mathematics, physics, and engineering.



Previous Article
Next Article

Similar Reads

Operator grammar and precedence parser in TOC
A grammar that is used to define mathematical operators is called an operator grammar or operator precedence grammar. Such grammars have the restriction that no production has either an empty right-hand side (null productions) or two adjacent non-terminals in its right-hand side. Examples - This is an example of operator grammar: E->E+E/E*E/id H
6 min read
Hypothesis (language regularity) and algorithm (L-graph to NFA) in TOC
Prerequisite - Finite automata, L-graphs and what they represent L-graphs can generate context sensitive languages, but it’s much harder to program a context sensitive language over programming a regular one. This is why I’ve came up with a hypothesis about what kind of L-graphs can generate a regular language. But first, I need to introduce you to
7 min read
Decidability, Semi-Decidability, and Undecidability in TOC
We know about Decidable, Semi-decidable, and Undecidable problems and in this article, we will briefly define these problems and provide the most commonly asked questions on these problems and classify them accordingly. Prerequisite - https://www.geeksforgeeks.org/decidable-and-undecidable-problems-in-theory-of-computation/ Introduction :Identifyin
3 min read
Recursive and Recursive Enumerable Languages in TOC
Recursive Enumerable (RE) or Type -0 Language RE languages or type-0 languages are generated by type-0 grammars. An RE language can be accepted or recognized by Turing machine which means it will enter into final state for the strings of language and may or may not enter into rejecting state for the strings which are not part of the language. It me
5 min read
Decidability and Undecidability in TOC
Identifying languages (or problems*) as decidable, undecidable or partially decidable is a very common question in GATE. With correct knowledge and ample experience, this question becomes very easy to solve. Lets start with some definitions:- Decidable language -A decision problem P is said to be decidable (i.e., have an algorithm) if the language
5 min read
Undecidability and Reducibility in TOC
Decidable Problems A problem is decidable if we can construct a Turing machine which will halt in finite amount of time for every input and give answer as ‘yes’ or ‘no’. A decidable problem has an algorithm to determine the answer for a given input. Examples Equivalence of two regular languages: Given two regular languages, there is an algorithm an
5 min read
Mealy and Moore Machines in TOC
Moore and Mealy Machines are Transducers that help in producing outputs based on the input of the current state or previous state. In this article we are going to discuss Moore Machines and Mealy Machines, the difference between these two machinesas well as Conversion from Moore to Mealy and Conversion from Mealy to Moore Machines. Moore Machines M
3 min read
Determining Countability in TOC
Countable Set is a set having cardinality same as that of some subset of N the set of natural numbers . A countable set is the one which is listable. Cardinality of a countable set can be a finite number. For example, B: {1, 5, 4}, |B| = 3, in this case its termed countably finite or the cardinality of countable set can be infinite. For example, A:
3 min read
Closure properties Table in TOC
The Below Table shows the Closure Properties of Formal Languages : REG = Regular LanguageDCFL = deterministic context-free languages, CFL = context-free languages,CSL = context-sensitive languages,RC = Recursive.RE = Recursive Enumerable Consider L and M are regular languages : The Kleene star - ∑*, is a unary operator on a set of symbols or string
3 min read
Reduction Theorem in TOC
Reduction Theorem :A reduction from A to B is a function f : ÎĢ1* → ÎĢ2* such that For any w ∈ ÎĢ1*, w ∈ A if f(w) ∈ B Every w ∈ A maps to some f(w) ∈ B.Every w ∉ A maps to some f(w) ∉ B.f does not have to be injective or surjective. Why Reductions Matter?If language A reduces to language B, we can use a recognizer / co-recognizer / decider for B to r
5 min read
Ladner's theorem in TOC
Ladner's theorem in TOC :As you presumably know, regardless of whether P = NP is a significant perplexing issue in field of Computer Science. In computational complexity, those problems which belongs to NP- problems but can't belong to P or NP-complete are known as NP-intermediate problems. Taking into account NP-complete issues, it is normal to ke
5 min read
Basic Theorems in TOC (Myhill nerode theorem)
The Myhill Nerode theorem is a fundamental result coming down to the theory of languages. This theory was proven by John Myhill and Anil Nerode in 1958. It is used to prove whether or not a language L is regular and it is also used for minimization of states in DFA( Deterministic Finite Automata). To understand this theorem, first we need to unders
3 min read
Turing Machine in TOC
Turing Machine was invented by Alan Turing in 1936 and it is used to accept Recursive Enumerable Languages (generated by Type-0 Grammar).  Turing machines are a fundamental concept in the theory of computation and play an important role in the field of computer science. They were first described by the mathematician and computer scientist Alan Turi
6 min read
Represent a number as sum of minimum possible pseudobinary numbers
Given a number, you have to represent this number as sum of minimum number of possible pseudobinary numbers. A number is said to be pseudobinary number if its decimal number consists of only two digits (0 and 1). Example: 11,10,101 are all pseudobinary numbers.Examples :- Input : 44 Output : 11 11 11 11 Explanation : 44 can be represented as sum of
6 min read
Check if a graphs has a cycle of odd length
Given a graph, the task is to find if it has a cycle of odd length or not. The idea is based on an important fact that a graph does not contain a cycle of odd length if and only if it is Bipartite, i.e., it can be colored with two colors. It is obvious that if a graph has an odd length cycle then it cannot be Bipartite. In Bipartite graph there are
12 min read
Rearrange array such that arr[i] >= arr[j] if i is even and arr[i]<=arr[j] if i is odd and j < i
Given an array of n elements. Our task is to write a program to rearrange the array such that elements at even positions are greater than all elements before it and elements at odd positions are less than all elements before it.Examples: Input : arr[] = {1, 2, 3, 4, 5, 6, 7} Output : 4 5 3 6 2 7 1 Input : arr[] = {1, 2, 1, 4, 5, 6, 8, 8} Output : 4
11 min read
Find speed of man from speed of stream and ratio of time with up and down streams
Program to find the speed of man in km/hr, given the speed of stream in km/hr. Assume that the man takes n times (where n > 1) as long to row upstream as to row downstream the river.Examples: Input : 5.5 4 Output : speed of man is 9.16667 km/hr Input : 4 3 Output : speed of man is 8 km/hr Approach Used :Let speed of the man in still water = x km
4 min read
Lex program to take input from file and remove multiple spaces, lines and tabs
FLEX (Fast Lexical Analyzer Generator) is a tool/computer program for generating lexical analyzers (scanners or lexers) written by Vern Paxson in C around 1987. Lex reads an input stream specifying the lexical analyzer and outputs source code implementing the lexer in the C programming language. The function yylex() is the main flex function which
2 min read
Maximum distance between i and j such that i â‰Ī j and A[i] â‰Ī B[j]
Given two non-increasing arrays A[] and B[] of size N, the task is to find the maximum distance between i and j such that i â‰Ī j and A[i] â‰Ī B[j]. Examples: Input: A[] = {2, 2, 2}, B[] = {10, 10, 1}Output: 1Explanation: The valid pairs satisfying the conditions are (0, 0), (0, 1), and (1, 1).Therefore, the maximum distance is 1 between the indices 0
11 min read
LEX Code to Identify and print Integer & Float Constants and Identifier
In this article, we will discuss how you can solve the problem, and also you will see how you can design problems related to DFA in LEX Code to Identify and print Integer & Float Constants and identifiers. Let's discuss it one by one. Problem Overview : Design a DFA in LEX Code to Identify and print Integer & Float Constants and identifiers
3 min read
Count N-length arrays of made up of elements not exceeding 2^K - 1 having maximum sum and Bitwise AND equal to 0
Given two integers N and K, the task is to find the number of N-length arrays that satisfies the following conditions: The sum of the array elements is maximum possible.For every possible value of i ( 1 ? i ? N ), the ith element should lie between 0 and 2K - 1.Also, Bitwise AND of all the array elements should be 0. Note: Since, the answer can be
7 min read
Check if array elements are consecutive in O(n) time and O(1) space (Handles Both Positive and negative numbers)
Given an unsorted array of distinct numbers, write a function that returns true if array consists of consecutive numbers. Examples : Input : arr[] = {5, 4, 2, 1, 3} Output : Yes Input : arr[] = {2, 1, 0, -3, -1, -2} Output : YesRecommended: Please solve it on “PRACTICE ” first, before moving on to the solution. We have discussed three different app
6 min read
Minimum number with digits as 4 and 7 only and given sum
Lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. What minimum lucky number has the sum of digits equal to n. Examples: Input : sum = 11 Output : 47 Sum of digits in 47 is 11 and 47 is the smallest number with given sum. Input : sum = 10 Output : -1 Recommended PracticeLucky number and a su
6 min read
Deep, Shallow and Lazy Copy with Java Examples
In object-oriented programming, object copying is creating a copy of an existing object, the resulting object is called an object copy or simply copy of the original object.There are several ways to copy an object, most commonly by a copy constructor or cloning.We can define Cloning as "create a copy of object". Shallow, deep and lazy copy is relat
4 min read
Permutation and Combination | Set-2
Question 1: How many number greater than ten thousand can be formed from the digits 0, 1, 2, 3, 4 without repetition ? Solution : In order to form a number greater than 10000 we should have only 5 digits. Since, we have 5 digits we cannot take 0 in starting position. _ _ _ _ For first digit, we have 4 choices. For second digit, again we have 4 choi
5 min read
Context-sensitive Grammar (CSG) and Language (CSL)
Context-Sensitive Grammar - A Context-sensitive grammar is an Unrestricted grammar in which all the productions are of form - Where Îą and Îē are strings of non-terminals and terminals. Context-sensitive grammars are more powerful than context-free grammars because there are some languages that can be described by CSG but not by context-free grammars
2 min read
Find time when hour and minute hands superimpose
This puzzle is an extension of the famous interview problem, find angle between hour and minute hand at any given time. The questions asks us to find the time when they both superimpose. The hour hand moves 360o in 12 hours and thus, 0.5 degrees in 1 min. The minute hands moves 360 degrees in 60 min, hence, 6 degrees in 1 minute. After H hours and
1 min read
Useful and time saving bash commands in Linux
There are many useful bash scripts that can make things easier. Many things can be done just using the terminal. Here is a list of some of such useful bash scripts through which we can do things that cannot be done manually. 1. Counting the number of files(or directory) in a given directory: Go to the directory in which you want to count the number
3 min read
An Ultimate Guide to Git and Github
Highlights of the article: Introduction to GitGit Repository StructureGithubAccessing Github central repository via HTTPS or sshWorking with git - Important Git commandsIntroduction to Git For installation purposes on ubuntu, you can refer to this article: How to Install, Configure and Use GIT on Ubuntu? Git is a distributed version control system.
8 min read
deque::clear() and deque::erase() in C++ STL
Deque or Double-ended queues are sequence containers with the feature of expansion and contraction on both ends. They are similar to vectors, but are more efficient in the case of insertion and deletion of elements at the end, and also at the beginning. Unlike vectors, contiguous storage allocation may not be guaranteed. deque::clear() The clear()
5 min read
Article Tags :
Practice Tags :