Hypothesis (language regularity) and algorithm (L-graph to NFA) in TOC
Last Updated :
19 May, 2023
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 what I call an iterating nest. As you can remember a nest is a neutral path T_1T_2T_3 , where T_1 and T_3 are cycles and T_2 path is neutral. We will call T_1T_2T_3 an iterating nest, if T_1 , T_2 and T_3 paths print the same string of symbols several times, to be more exact T_1 prints \alpha^k , T_2 prints \alpha^l , T_3 prints \alpha^m , k, \: l, \: m \geqslant 0 and \alpha is a string of input symbols (better, if at least one of k, \: l\: and\: m\: is \geqslant 1 ). From this definition comes out the next hypothesis. Hypothesis - If in a context free L-graph G all nests are iterating, then the language defined by this L-graph G, L(G), is regular. If this hypothesis will be proven in the near future, it can change a lot in programming that will make creating new easy programming languages much easier than it already is. The hypothesis above leads to the next algorithm of converting context free L-graphs with iterating nests to an NFA. Algorithm - Converting a context free L-graph with iterating complements to a corresponding NFA Input - Context free L-graph G=(\Sigma, V, P, \lambda, P_0, F) with iterating complements Output - G’=(\Sigma’, V’, \lambda’, P’_0, F’)\\*
- Step-1: Languages of the L-graph and NFA must be the same, thusly, we won’t need a new alphabet \Rightarrow \Sigma’’ = \Sigma, \: P’’ = P . (Comment: we build context free L-graph G’’, which is equal to the start graph G’, with no conflicting nests)
- Step-2: Build Core(1, 1) for the graph G. V’’ := {(v, \varepsilon ) | v \in V of \forall canon k \in Core(1, 1), v \notin k} \lambda'' := { arcs o \in \lambda | start and final states o', o'' \in V’’} For all k \in Core(1, 1): Step 1’. v := 1st state of canon k. \eta := \varepsilon . V’’ \cup= (v, \eta) Step 2’. \lambda'' \cup= arc from state (v, \eta) followed this arc into new state defined with following rules: \eta := \eta , if the input bracket on this arc = \varepsilon ; \eta'the\: input\: bracket' , if the input bracket is an opening one; \eta 'without\: the\: last\: bracket' , if the input bracket is a closing bracket v := 2nd state of canon k V’’ \cup= (v, \eta) Step 3’. Repeat Step 2’, while there are still arcs in the canon.
- Step-3: Build Core(1, 2). If the canon has 2 equal arcs in a row: the start state and the final state match; we add the arc from given state into itself, using this arc, to \lambda'' . Add the remaining in \lambda arcs v – u (\alpha) to \lambda'' in the form of (v, \varepsilon) - (u, \varepsilon) (\alpha)
- Step-4: P''_0 = (P_0, \varepsilon).\: F'' = \{(f, \varepsilon) | f \in F\} (Comment: following is an algorithm of converting context free L-graph G’’ into NFA G’)
- Step-5: Do the following to every iterating complement T = T_1T_2T_3 in G’’: Add a new state v. Create a path that starts in state beg(T_3) , equal to T_3 . From v into T_3 create the path, equal to T_1 . Delete cycles T_1 and T_3 .
- Step-6: G’ = G’’, where arcs are not loaded with brackets.
So that every step above is clear I’m showing you the next example. \textbf{Example:}\\ \textbf{Input:} Context free L-graph with iterating complements G = ( \{a, b, c\}, \\*\{1, 2, 3\} \\*\{( (, ) ), ( [, ] )\}, \\*\\*\{ (: \{ 1 – a – 1 \}, \\*): \{ 2 – a – 2 \}, \\*\big[: \{ 1 – b – 2 \}, \\*\big]: \{ 2 – c – 3 \}, \\*\varepsilon: \{ 1 – a – 2 \} \}, \\*\\*1, \\*\{2, 3\} \} , which determines the language = \{a^(^2^n^+^1^) | n \geqslant 0\} \cup \{bc\}
Start graph G \Sigma'' = \{a, b, c\}\\ V’’ = \varnothing\\ \lambda’’ = \varnothing Core(1, 1) = { 1 – a – 2 ; 1 – a, (1 – 1 – a – 2 – a, )1 – 2 ; 1 – b, (2 – 2 – c, )2 – 3 } Core(1, 2) = Core(1, 1) \cup { 1 – a, (1 – 1 – a, (1 – 1 – a – 2 – a, )1 – 2 – a, )1 – 2 } Step 2: Step 1’ – Step 3’ \Rightarrow\\ V’’ = \{(1, \varepsilon), (2, (_2), (3, \varepsilon), (1, (_1), (2, )_1), (2, \varepsilon)\}\\* \lambda’’ = \{ \\*(: \{ (1, \varepsilon) – a – (1, (); (1, () – a – (1, () \}, \\*): \{ (2, )) – a – (2, )); (2, )) – a – (2, \varepsilon) \}, \\*\big[: \{ (1, \varepsilon) – b – (2, [) \}, \\*\big]: \{ (2, [) – c – (3, \varepsilon) \}, \\*\varepsilon: \{ (1, \varepsilon) – a – (2, \varepsilon); (1, () – a – (2, )) \} \}\\ P’’_0 = (1, \varepsilon)\\ F’’ = \{(2, \varepsilon), (3, \varepsilon)\}\\ G’’ = (\Sigma’’, V’’, P’’, \lambda’’, P’’_0, F’’)
Intermediate graph G’’ \Sigma’ = \{a, b, c\}\\ V’ = V’’ \cup \{4\}\\ P’_0 = P’’_0\\ F’ = F’’\\ \lambda’ = \{ \\*(1, \varepsilon) – a – (1, (); \\*(2, )) – a – 4; \\*4 – a – (2, )); \\*(2, )) – a – (2, \varepsilon); \\*(1, \varepsilon) – b – (2, [); \\*(2, [) – c – (3, \varepsilon); \\*(1, \varepsilon) – a – (2, \varepsilon); \\*(1, () – a – (2, )) \}\\ G’ = (\Sigma’, V’, \lambda’, P’_0, F’)
NFA G’
Advantages of hypotheses (language regularity) in TOC:
Framework for analysis: Hypotheses about language regularity provide a structured framework for analyzing and classifying languages. By categorizing languages into different classes (e.g., regular, context-free, etc.), researchers can study the properties, limitations, and computational complexities associated with each class.
Understanding language behavior: Hypotheses about language regularity help in understanding the behavior of languages. Regular languages, for example, have well-defined properties and can be recognized by finite automata. By assuming the regularity of a language, researchers can employ known techniques and tools to analyze and process the language efficiently.
Bridging theory and practice: Hypotheses related to language regularity act as a bridge between theoretical foundations and practical applications. The study of regular languages allows for the development of algorithms and techniques that are widely applicable in areas such as compiler design, pattern matching, and text processing.
Disadvantages of hypotheses (language regularity) in TOC:
Limitations of classification: Hypotheses about language regularity rely on a classification system that may have inherent limitations. Not all languages fit neatly into predefined classes, and some languages may possess properties that fall outside traditional categorizations. This can make it challenging to accurately classify languages and determine their regularity.
Complex languages: Hypotheses about language regularity often focus on simpler languages, such as regular languages. However, real-world problems and applications may involve more complex languages, such as context-free or context-sensitive languages. In such cases, the regularity assumption may not hold, and alternative approaches or formalisms may be necessary.
Similar Reads
Automata Tutorial Automata Theory is a branch of the Theory of Computation. It deals with the study of abstract machines and their capacities for computation. An abstract machine is called the automata. It includes the design and analysis of automata, which are mathematical models that can perform computations on str
3 min read
Automata _ Introduction
Regular Expression and Finite Automata
Introduction of Finite AutomataFinite automata are abstract machines used to recognize patterns in input sequences, forming the basis for understanding regular languages in computer science. They consist of states, transitions, and input symbols, processing each symbol step-by-step. If the machine ends in an accepting state after
4 min read
Arden's Theorem in Theory of ComputationA Regular Expression (RE) is a way to describe patterns of strings using symbols and operators like union, concatenation, and star. A Deterministic Finite Automaton (DFA) is a machine that reads input strings and decides if they match the pattern by moving through a set of defined states without any
6 min read
Solving Automata Using Arden's TheoremArden's Theorem states that, if P & Q are two regular expressions over âââ, and if P does not contain âââ, then the following equation R given by R = Q + RP has a unique solution ; R = QP* For certain examples provided below, itâs fairly simple to derive them. But for the following example, it'
6 min read
L-graphs and what they represent in TOCIn 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, Has
4 min read
Hypothesis (language regularity) and algorithm (L-graph to NFA) in TOCPrerequisite - 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 regul
7 min read
Regular Expressions, Regular Grammar and Regular LanguagesTo work with formal languages and string patterns, it is essential to understand regular expressions, regular grammar, and regular languages. These concepts form the foundation of automata theory, compiler design, and text processing.Regular ExpressionsRegular expressions are symbolic notations used
7 min read
How to identify if a language is regular or notPrerequisite - Regular Expressions, Regular Grammar and Regular Languages, Pumping Lemma There is a well established theorem to identify if a language is regular or not, based on Pigeon Hole Principle, called as Pumping Lemma. But pumping lemma is a negativity test, i.e. if a language doesn't satisf
8 min read
Designing Finite Automata from Regular Expression (Set 1)In this article, we will see some popular regular expressions and how we can convert them to finite automata. Even number of a's : The regular expression for even number of a's is (b|ab*ab*)*. We can construct a finite automata as shown in Figure 1. The above automata will accept all strings which h
3 min read
Star Height of Regular Expression and Regular LanguageThe star height relates to the field of theoretical computation (TOC). It is used to indicate the structural complexity of regular expressions and regular languages. In this context, complexity refers to the maximum nesting depth of Kleene stars present in a regular expression.A regular language may
3 min read
Generating regular expression from Finite AutomataPrerequisite - Introduction of FA, Regular expressions, grammar and language, Designing FA from Regular Expression There are two methods to convert FA to the regular expression: 1. State Elimination Method:Step 1 - If the start state is an accepting state or has transitions in, add a new non-accepti
3 min read
Code Implementation of Deterministic Finite Automata (Set 1)In this article, we will learn about designing of Deterministic Finite Automata (DFA) and it's code implementation.Problem-1: Construction of a DFA for the set of string over {a, b} such that length of the string |w|=2 i.e, length of the string is exactly 2.Explanation - The desired language will be
8 min read
Program for Deterministic Finite Automata (Set 2)In this article, we will learn about designing of Deterministic Finite Automata (DFA) and it's code implementation. Problem-1:Construction of a DFA for the set of string over {a, b} such that length of the string |w| is divisible by 2 i.e, |w| mod 2 = 0. Explanation - The desired language will be li
7 min read
DFA for Strings not ending with "THE"Problem - Accept Strings that not ending with substring "THE". Check if a given string is ending with "the" or not. The different forms of "the" which are avoided in the end of the string are: "THE", "ThE", "THe", "tHE", "thE", "The", "tHe" and "the" All those strings that are ending with any of the
12 min read
DFA of a string with at least two 0âs and at least two 1âsProblem - Draw deterministic finite automata (DFA) of a string with at least two 0âs and at least two 1âs. The first thing that come to mind after reading this question us that we count the number of 1's and 0's. Thereafter if they both are at least 2 the string is accepted else not accepted. But we
3 min read
DFA for accepting the language L = { anbm | n+m =even }ProblemDesign a deterministic finite automata(DFA) for accepting the language L = {an bm | n+m = even}Examples:Input: a a b b , n = 2, m = 2 2 + 2 = 4 (even)Output: ACCEPTEDInput: a a a b b b b ,n = 3, m = 43 + 4 = 7 (odd) Output: NOT ACCEPTEDInput: a a a b b b , n = 3, m = 33 + 3 = 6 (even)Output:
14 min read
DFA machines accepting odd number of 0âs or/and even number of 1âsPrerequisite - Designing finite automata Problem - Construct a DFA machine over input alphabet \sum_= {0, 1}, that accepts: Odd number of 0âs or even number of 1âs Odd number of 0âs and even number of 1âs Either odd number of 0âs or even number of 1âs but not the both together Solution - Let first d
3 min read
DFA of a string in which 2nd symbol from RHS is 'a'Draw deterministic finite automata (DFA) of the language containing the set of all strings over {a, b} in which 2nd symbol from RHS is 'a'. The strings in which 2nd last symbol is "a" are: aa, ab, aab, aaa, aabbaa, bbbab etc Input/Output INPUT : baba OUTPUT: NOT ACCEPTED INPUT: aaab OUTPUT: ACCEPTED
10 min read
Union Process in DFAIn theory of computation, union of two Deterministic Finite Automata (DFAs) is an operation used to construct a new DFA that recognizes union of languages accepted by the original automata. For example, two DFAs each recognizing a language L1â and L2â respectively, their union DFA will accept any st
4 min read
Concatenation Process in DFAIn the context of Deterministic Finite Automata (DFA), concatenation refers to the process of combining two regular languages (or strings) together to form a new language.DFA is a model used to recognize patterns or decide if a string belongs to a particular language.Concatenation is simply taking t
3 min read
DFA in LEX code which accepts even number of zeros and even number of onesLex is a computer program that generates lexical analyzers, which is commonly used with the YACC parser generator. Lex, originally written by Mike Lesk and Eric Schmidt and described in 1975, is the standard lexical analyzer generator on many Unix systems, and an equivalent tool is specified as part
6 min read
Conversion from NFA to DFAAn NFA can have zero, one or more than one move from a given state on a given input symbol. An NFA can also have NULL moves (moves without input symbol). On the other hand, DFA has one and only one move from a given state on a given input symbol. Steps for converting NFA to DFA:Step 1: Convert the g
5 min read
Minimization of DFADFA minimization stands for converting a given DFA to its equivalent DFA with minimum number of states. DFA minimization is also called as Optimization of DFA and uses partitioning algorithm.Minimization of DFA Suppose there is a DFA D < Q, Î, q0, Î, F > which recognizes a language L. Then the
7 min read
Reversing Deterministic Finite AutomataPrerequisite â Designing finite automata Reversal: We define the reversed language L^R \text{ of } L  to be the language L^R = \{ w^R \mid w \in L \} , where w^R := a_n a_{n-1} \dots a_1 a_0 \text{ for } w = a_0 a_1 \dots a_{n-1} a_n Steps to Reversal: Draw the states as it is.Add a new single accep
4 min read
Complementation process in DFAPrerequisite â Design a Finite automata Suppose we have a DFA that is defined by ( Q, \Sigma  , \delta  , q0, F ) and it accepts the language L1. Then, the DFA which accepts the language L2 where L2 = Ì
L1', will be defined as below:Â Â ( Q, \Sigma, \delta, q0, Q-F )The complement of a DFA can be obtai
2 min read
Kleene's Theorem in TOC | Part-1A language is said to be regular if it can be represented by using Finite Automata or if a Regular Expression can be generated for it. This definition leads us to the general definition that; For every Regular Expression corresponding to the language, a Finite Automata can be generated. For certain
4 min read
Mealy and Moore Machines in TOCMoore 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 Convers
3 min read
Difference Between Mealy Machine and Moore MachineIn theory of computation and automata, there are two machines: Mealy Machine and Moore Machine which is used to show the model and behavior of circuits and diagrams of a computer. Both of them have transition functions and the nature of taking output on same input is different for both. In this arti
4 min read
CFG
Relationship between grammar and language in Theory of ComputationIn the Theory of Computation, grammar and language are fundamental concepts used to define and describe computational problems. A grammar is a set of production rules that generate a language, while a language is a collection of strings that conform to these rules. Understanding their relationship i
4 min read
Simplifying Context Free GrammarsA Context-Free Grammar (CFG) is a formal grammar that consists of a set of production rules used to generate strings in a language. However, many grammars contain redundant rules, unreachable symbols, or unnecessary complexities. Simplifying a CFG helps in reducing its size while preserving the gene
6 min read
Closure Properties of Context Free LanguagesContext-Free Languages (CFLs) are an essential class of languages in the field of automata theory and formal languages. They are generated by context-free grammars (CFGs) and are recognized by pushdown automata (PDAs). Understanding the closure properties of CFLs helps in determining which operation
11 min read
Union and Intersection of Regular languages with CFLContext-Free Languages (CFLs) are an essential class of languages in the field of automata theory and formal languages. They are generated by context-free grammars (CFGs) and are recognized by pushdown automata (PDAs). Understanding the closure properties of CFLs helps in determining which operation
3 min read
Converting Context Free Grammar to Chomsky Normal FormChomsky Normal Form (CNF) is a way to simplify context-free grammars (CFGs) so that all production rules follow specific patterns. In CNF, each rule either produces two non-terminal symbols, or a single terminal symbol, or, in some cases, the empty string. Converting a CFG to CNF is an important ste
5 min read
Converting Context Free Grammar to Greibach Normal FormContext-free grammar (CFG) and Greibach Normal Form (GNF) are fundamental concepts in formal language theory, particularly in the field of compiler design and automata theory. This article delves into what CFG and GNF are, provides examples, and outlines the steps to convert a CFG into GNF.What is C
6 min read
Pumping Lemma in Theory of ComputationThere are two Pumping Lemmas, which are defined for 1. Regular Languages, and 2. Context - Free Languages Pumping Lemma for Regular Languages For any regular language L, there exists an integer n, such that for all x ? L with |x| ? n, there exists u, v, w ? ?*, such that x = uvw, and (1) |uv| ? n (2
4 min read
Check if the language is Context Free or NotIdentifying regular languages is straightforward, but determining if a language is context-free can be tricky. Since the Pumping Lemma requires mathematical proof, it is time-consuming. Instead, observational techniques help quickly determine whether a language is context-free.Pumping Lemma for Cont
4 min read
Ambiguity in Context free Grammar and LanguagesContext-Free Grammars (CFGs) are essential in formal language theory and play a crucial role in programming language design, compiler construction, and automata theory. One key challenge in CFGs is ambiguity, which can lead to multiple derivations for the same string.Understanding Derivation in Cont
3 min read
Operator grammar and precedence parser in TOCA 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
6 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
2 min read
PDA (Pushdown Automata)
Introduction of Pushdown AutomataWe have already discussed finite automata. But finite automata can be used to accept only regular languages. Pushdown Automata is a finite automata with extra memory called stack which helps Pushdown automata to recognize Context Free Languages. This article describes pushdown automata in detail.Pus
5 min read
Pushdown Automata Acceptance by Final StateWe have discussed Pushdown Automata (PDA) and its acceptance by empty stack article. Now, in this article, we will discuss how PDA can accept a CFL based on the final state. Given a PDA P as: P = (Q, Σ, Î, δ, q0, Z, F) The language accepted by P is the set of all strings consuming which PDA can move
4 min read
Construct Pushdown Automata for given languagesPrerequisite - Pushdown Automata, Pushdown Automata Acceptance by Final State A push down automata is similar to deterministic finite automata except that it has a few more properties than a DFA.The data structure used for implementing a PDA is stack. A PDA has an output associated with every input.
4 min read
Construct Pushdown Automata for all length palindromeA Pushdown Automata (PDA) is like an epsilon Non deterministic Finite Automata (NFA) with infinite stack. PDA is a way to implement context free languages. Hence, it is important to learn, how to draw PDA. Here, take the example of odd length palindrome:Que-1: Construct a PDA for language L = {wcw'
6 min read
Detailed Study of PushDown AutomataAccording to the Chomsky Hierarchy, the requirement of a certain type of grammar to generate a language is often clubbed with a suitable machine that can be used to accept the same language. When the grammar is simple, the language becomes more complex, hence we require a more powerful machine to un
3 min read
NPDA for accepting the language L = {anbm cn | m,n>=1}Before attempting this problem, you should have a working knowledge of Pushdown Automata concepts.ProblemThe problem can be solved if you have prior knowledge about NPDA.Design a non deterministic PDA for accepting the language L = {an bm cn | m, n >= 1}, i.e., L = { abc, abbc, abbbc, aabbcc, aaa
2 min read
NPDA for accepting the language L = {an bn cm | m,n>=1}Prerequisite: Basic Knowledge of Pushdown Automata.ProblemDesign a non deterministic PDA for accepting the language L = {anbncm | m, n>=1}, i.e., L = { abc, abcc, abccc, aabbc, aaabbbcc, aaaabbbbccccc, ...... } In each of the string, the number of a's is equal to number of b's and the number of c
2 min read
NPDA for accepting the language L = {anbn | n>=1}Prerequisite: Basic knowledge of pushdown automata.Problem :Design a non deterministic PDA for accepting the language L = {an bn | n>=1}, i.e.,L = {ab, aabb, aaabbb, aaaabbbb, ......} In each of the string, the number of a's are followed by equal number of b's. ExplanationHere, we need to maintai
2 min read
NPDA for accepting the language L = {amb2m| m>=1}ProblemDesign a non deterministic PDA for accepting the language L = {am ,b2m | m>=1}L = {abb, aabbbb, aaabbbbbb, aaaabbbbbbbb, ......} In each of the string, the number of a's are followed by double number of b's. Explanation - Here, we need to maintain the order of aâs and bâs. That is, all the
2 min read
NPDA for accepting the language L = {am bn cp dq | m+n=p+q ; m,n,p,q>=1}Prerequisite - Pushdown automata, Pushdown automata acceptance by final state Problem - Design a non deterministic PDA for accepting the language L = {a^m b^n c^p d^q | m + n = p + q : m, n, p, q>=1}, i.e., L = {abcd, abbcdd, abbccd, abbbccdd, ......} In each of the string, the total number of 'a
2 min read
Construct Pushdown automata for L = {0n1m2m3n | m,n ⥠0}Prerequisite - Pushdown automata, Pushdown automata acceptance by final state Pushdown automata (PDA) plays a significant role in compiler design. Therefore there is a need to have a good hands on PDA. Our aim is to construct a PDA for L = {0n1m2m3n | m,n ⥠0} Examples - Input : 00011112222333 Outpu
3 min read
Construct Pushdown automata for L = {0n1m2n+m | m, n ⥠0}Prerequisite : PDA plays a very important role in task of compiler designing. Therefore, there is a need to have good practice on PDA. ProblemConstruct a PDA which accepts a string of the form { 0 n 1 m 2 m+n | m , n >=0 } ExamplesInput: 00001111 ( case 1 )Output: AcceptedInput: 111222 (case 2)Ou
2 min read
NPDA for accepting the language L = {ambncm+n | m,n ⥠1}The problem below require basic knowledge of Pushdown Automata.Problem Design a non deterministic PDA for accepting the language L = {am bn cm+n | m,n ⥠1} for eg. ,L = {abcc, aabccc, abbbcccc, aaabbccccc, ......} In each of the string, the total sum of the number of 'aâ and 'b' is equal to the numb
2 min read
NPDA for accepting the language L = {amb(m+n)cn| m,n ⥠1}A solid understanding of pushdown automata and their input acceptance via final states is essential before proceeding with this topic.Problem Design a non deterministic PDA for accepting the language L = {am b(m+n) cn | m,n ⥠1}.The strings of given language will be: L = {abbc, abbbcc, abbbcc, aabbb
3 min read
NPDA for accepting the language L = {a2mb3m|m>=1}Before learning this, you should know about pushdown automata and how they accept inputs using final states.Problem Design a non deterministic PDA for accepting the language L = {a2mb3m| m ⥠1}, i.e., L = {aabbb, aaaabbbbbb, aaaaaabbbbbbbbb, aaaaaaaabbbbbbbbbbbb, ......} In each of the string, for e
2 min read
NPDA for accepting the language L = {amb2m+1 | m ⥠1}ProblemDesign a non deterministic PDA for accepting the language L = { am b2m+1 | m ⥠1} or L = { am b b2m | m ⥠1}, i.e.,L = {abbb, aabbbbb, aaabbbbbbb, aaaabbbbbbbbb, ......}In each of the string, the number of 'b' is one more than the twice of the number of 'a'. ExplanationHere, we need to mainta
2 min read
NPDA for accepting the language L = {aibjckdl | i==k or j==l,i>=1,j>=1}Prerequisite - Pushdown automata, Pushdown automata acceptance by final state Problem - Design a non deterministic PDA for accepting the language L = {a^i b^j c^k d^l : i==k or j==l, i>=1, j>=1}, i.e., L = {abcd, aabccd, aaabcccd, abbcdd, aabbccdd, aabbbccddd, ......} In each string, the numbe
3 min read
Construct Pushdown automata for L = {a2mc4ndnbm | m,n ⥠0}Pushdown Automata plays a very important role in task of compiler designing. That is why there is a need to have a good practice on PDA. Our objective is to construct a PDA for L = {a2mc4ndn bm | m,n ⥠0} Example:Input: aaccccdbOutput: AcceptedInput: aaaaccccccccddbbOutput: AcceptedInput: acccddbOut
3 min read
NPDA for L = {0i1j2k | i==j or j==k ; i , j , k >= 1}Prerequisite - Pushdown automata, Pushdown automata acceptance by final state The language L = {0i1j2k | i==j or j==k ; i , j , k >= 1} tells that every string of â0â, â1â and â2â have certain number of 0âs, then certain number of 1âs and then certain number of 2âs. The condition is that count of
2 min read
NPDA for accepting the language L = {anb2n| n>=1} U {anbn| n>=1}To understand this question, you should first be familiar with pushdown automata and their final state acceptance mechanism.ProblemDesign a non deterministic PDA for accepting the language L = {an b2n : n>=1} U {an bn : n>=1}, i.e.,L = {abb, aabbbb, aaabbbbbb, aaaabbbbbbbb, ......} U {ab, aabb
2 min read
NPDA for the language L ={wÐ{a,b}* | w contains equal no. of a's and b's}A solid understanding of pushdown automata fundamentals is essential for this question.ProblemDesign a non deterministic PDA for accepting the language L ={wÐ{a,b}* | w contains equal no. of a's and b's}, i.e.,L = {ab, aabb, abba, aababb, bbabaa, baaababb, .......} The number of a's and b's are same
3 min read
Turing Machine
Recursive and Recursive Enumerable Languages in TOCRecursive Enumerable (RE) or Type -0 LanguageRE 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
5 min read
Turing Machine in TOCTuring Machines (TM) play a crucial role in the Theory of Computation (TOC). They are abstract computational devices used to explore the limits of what can be computed. Turing Machines help prove that certain languages and problems have no algorithmic solution. Their simplicity makes them an effecti
7 min read
Turing Machine for additionPrerequisite - Turing Machine A number is represented in binary format in different finite automata. For example, 5 is represented as 101. However, in the case of addition using a Turing machine, unary format is followed. In unary format, a number is represented by either all ones or all zeroes. For
3 min read
Turing machine for subtraction | Set 1Prerequisite - Turing Machine Problem-1: Draw a Turing machine which subtract two numbers. Example: Steps: Step-1. If 0 found convert 0 into X and go right then convert all 0's into 0's and go right.Step-2. Then convert C into C and go right then convert all X into X and go right.Step-3. Then conver
2 min read
Turing machine for multiplicationPrerequisite - Turing Machine Problem: Draw a turing machine which multiply two numbers. Example: Steps: Step-1. First ignore 0's, C and go to right & then if B found convert it into C and go to left. Step-2. Then ignore 0's and go left & then convert C into C and go right. Step-3. Then conv
2 min read
Turing machine for copying dataPrerequisite - Turing Machine Problem - Draw a Turing machine which copy data. Example - Steps: Step-1. First convert all 0's, 1's into 0's, 1's and go right then B into C and go left Step-2. Then convert all 0's, 1's into 0's, 1's and go left then Step-3. If 1 convert it into X and go right convert
2 min read
Construct a Turing Machine for language L = {0n1n2n | nâ¥1}Prerequisite - Turing Machine The language L = {0n1n2n | nâ¥1} represents a kind of language where we use only 3 character, i.e., 0, 1 and 2. In the beginning language has some number of 0's followed by equal number of 1's and then followed by equal number of 2's. Any such string which falls in this
3 min read
Construct a Turing Machine for language L = {wwr | w ∈ {0, 1}}The language L = {wwres | w â {0, 1}} represents a kind of language where you use only 2 character, i.e., 0 and 1. The first part of language can be any string of 0 and 1. The second part is the reverse of the first part. Combining both these parts a string will be formed. Any such string that falls
5 min read
Construct a Turing Machine for language L = {ww | w ∈ {0,1}}Prerequisite - Turing Machine The language L = {ww | w â {0, 1}} tells that every string of 0's and 1's which is followed by itself falls under this language. The logic for solving this problem can be divided into 2 parts: Finding the mid point of the string After we have found the mid point we matc
7 min read
Construct Turing machine for L = {an bm a(n+m) | n,mâ¥1}Problem : L = { anbma(n +m) | n , m ⥠1} represents a kind of language where we use only 2 character, i.e., a and b. The first part of language can be any number of "a" (at least 1). The second part be any number of "b" (at least 1). The third part of language is a number of "a" whose count is sum o
3 min read
Construct a Turing machine for L = {aibjck | i*j = k; i, j, k ⥠1}Prerequisite â Turing Machine In a given language, L = {aibjck | i*j = k; i, j, k ⥠1}, where every string of 'a', 'b' and 'c' has a certain number of a's, then a certain number of b's and then a certain number of c's. The condition is that each of these 3 symbols should occur at least once. 'a' and
2 min read
Turing machine for 1's and 2âs complementProblem-1:Draw a Turing machine to find 1's complement of a binary number. 1âs complement of a binary number is another binary number obtained by toggling all bits in it, i.e., transforming the 0 bit to 1 and the 1 bit to 0. Example:1's ComplementApproach:Scanning input string from left to rightConv
3 min read
Recursive and Recursive Enumerable Languages in TOCRecursive Enumerable (RE) or Type -0 LanguageRE 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
5 min read
Turing Machine for subtraction | Set 2Prerequisite â Turing Machine, Turing machine for subtraction | Set 1 A number is represented in binary format in different finite automatas like 5 is represented as (101) but in case of subtraction Turing Machine unary format is followed . In unary format a number is represented by either all ones
2 min read
Halting Problem in Theory of ComputationThe halting problem is a fundamental issue in theory and computation. The problem is to determine whether a computer program will halt or run forever.Definition: The Halting Problem asks whether a given program or algorithm will eventually halt (terminate) or continue running indefinitely for a part
4 min read
Turing Machine as ComparatorPrerequisite â Turing MachineProblem : Draw a turing machine which compare two numbers. Using unary format to represent the number. For example, 4 is represented by 4 = 1 1 1 1 or 0 0 0 0 Lets use one's for representation. Example: Approach: Comparing two numbers by comparing number of '1's.Comparin
3 min read
Decidability
TOC Interview preparation
TOC Quiz and PYQ's in TOC