In order to understand the relationship between the grammar and language in the theory of computation (TOC), let us understand what is language generated by grammar in TOC.Language generated by grammarThe grammar is S-> aSb| E.In this grammar, by using S-> E, we can generate E.Therefore, E is part of L(G).Similarly, by using S=>aSb=>ab, ab is generated.Similarly, aabb can also be generated.Therefore, the result is as follows −L(G) = {anbn, n>0}In language L(G) which is discussed above, the condition n =0 is taken to accept the epsilon.Consider the grammar given belowS -> aSa | bSb | a |bNow, let us ... Read More
The language for the given regular expression (RE) is as follows −L={ ε,aa,ab,ba,aaaa,………}ExampleLet the regular expression be ((a+b)(a+b))*(a+b).Construct the Finite automata for the given regular expression.First, generate the language for the given Regular Expression −L={a,d,aaa,bbb,abb,bab,bba,………..}This is the language of odd length stringsThe Finite Automata is as follows −
To convert the regular expression to Finite Automata (FA) we can use the Subset method.Subset method is used to obtain FA from the given regular expression (RE).Step 1 − Construct a Transition diagram for a given RE using Non-deterministic finite automata (NFA) with ε moves.Step 2 − Convert NFA with ε to NFA without ε.Step 3 − Convert the NFA to equivalent DFA.We will divide the given expression into three parts as follows −“1” ,”(0+1)*, and “0”NFA with Epsilon transition is as follows −Now, we will remove the epsilon transition.After removing, the transition diagram is given below −
The regular expression R= a+ba* divided into r1 and r2r1= a and r2= ba*Let us draw Non-deterministic finite automata (NFA) for r1 as given below −Now, we will go for r2 = ba *Divide r2 into r3 and r4, where, r3=b and r4=a*The NFA for r3 is as follows −The NFA for r4 is as follows −q5 on epsilon movies goes to q6 and q8, q6 on ‘a’ goes to q7 whereas, q7 on epsilon moves goes to q6 as well as q7.r2= r3.r4Now, concatenate r3 and r4 as shown below −q3 on input ‘b’ goes to q4, q4 on ... Read More
Induction is a powerful tool in mathematics. It is a way of proving propositions that hold for all natural numbers.Hypothesis − The formal proof can be using deductive proof and inductive proof. The deductive proof consists of sequence of statements given with logical reasoning in order to prove the first or initial statement. The initial statement is called Hypothesis.Suppose there exists a k > 0 such that for any regular expression r where 0 < OP(r) < k, there exists an NFA- s such that L(M) = L(r). Furthermore, suppose that M has exactly one final state.Inductive StepLet r be ... Read More
To convert the regular expression (RE) to Finite Automata (FA), we can use the Subset method.Subset method is used to obtain FA from the given RE.Step 1 − Construct a Transition diagram for a given RE by using Non-deterministic finite automata (NFA) with ε moves.Step 2 − Convert NFA with ε to NFA without ε.Step 3 − Convert the NFA to the equivalent Deterministic Finite Automata (DFA).Some basic RE are as follows −Case 1 − For a regular expression ‘a’, we can construct FA as shown below −Case 2 − For a regular expression ‘ab’ we can construct FA, as ... Read More
In order to understand the relationship between finite automata (FA) and regular expression (RE), we need to understand these terminologies. Let us begin by understanding what is a regular expression.Regular ExpressionRegular expression is the language which is used to describe the language and is accepted by finite automata. Regular expressions are the most effective way to represent any language. Let Σ be an alphabet which denotes the input set.The regular expression over Σ can be defined as follows −Φ is a regular expression which denotes the empty set.ε is a regular expression and denotes the set { ε} and it ... Read More
Regular expression is the language which is used to describe the language and is accepted by finite automata. Regular expressions are the most effective way to represent any language. Let Σ be an alphabet which denotes the input set.The regular expression over Σ can be defined as follows −Φ is a regular expression which denotes the empty set.ε is a regular expression and denotes the set { ε} and it is called a null string.For each ‘a’ in Σ ‘a’ is a regular expression and denotes the set {a}.If r and s regular expressions denoting the language.L1 and l2 respectively ... Read More
Regular expression is the language which is used to describe the language and is accepted by finite automata. Regular expressions are the most effective way to represent any language. Let Σ be an alphabet which denotes the input set.The regular expression over Σ can be defined as follows −Φ is a regular expression which denotes the empty set.ε is a regular expression and denotes the set { ε} and it is called a null string.For each ‘a’ in Σ ‘a’ is a regular expression and denotes the set {a}.If r and s regular expressions denoting the language.L1 and l2 respectively ... Read More
Problem 1Write the regular expression for the language accepting all the strings containing any number of a's and b's.SolutionThe regular expression will be −r.e. = (a + b)*This will give the set as L = {E, a, aa, b, bb, ab, ba, aba, bab, .....}, any combination of a and b.The (a + b)* shows any combination with a and b even a null string.Problem 2Write the regular expression for the language starting with a but not having consecutive b's.SolutionThe regular expression has to be built for the language: L = {a, aba, aab, aba, aaa, abab, .....}The regular expression ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP