📘 Lecture 8 — Examples of TGs: accepting all strings, accepting none, starting with b, not ending in b, containing aa, containing aa or bb
📖 Overview: This lecture introduces Transition Graphs (TGs) as a more general model than Finite Automata (FA). It demonstrates through multiple examples how TGs can be constructed to accept specific languages, including the empty language, and explains the crucial relationship that every FA is a TG, but not every TG is an FA.
🗂️ Topics Covered
The lecture covers the definition of a TG's acceptance criteria (at least one path from initial to final state), examples of TGs accepting different languages (all strings including Λ, empty language, strings starting with b, strings not ending in b, strings containing aa, strings containing aa or bb), and the relationship between TGs and FAs.
📝 Lecture Summary
Note
It is to be noted that in TG there may exist more than one paths for a certain string, while there may not exist any path for a certain string as well. If there exists at least one path for a certain string, starting from initial state and ending in a final state, the string is supposed to be accepted by the TG, otherwise the string is supposed to be rejected. Obviously collection of accepted strings is the language accepted by the TG.
Example
Consider the Language L , defined over Σ = {a, b} of all strings including Λ. The language L may be accepted by the following TG
TG₁: a,b a,b
The language L may also be accepted by the following TG
TG₂: a,b
💡 Why this matters: A TG that accepts all strings, including the empty string Λ, can be as simple as a single initial-final state with a loop for all alphabet letters.
Example
Consider the following TGs
TG₁:
TG₂:
TG₃: a,b
It may be observed that in the first TG, no transition has been shown. Hence this TG does not accept any string, defined over any alphabet. In TG₂ there are transitions for a and b at initial state but there is no transition at state 1. This TG still does not accept any string. In TG₃ there are transitions at both initial state and state 1, but it does not accept any string.
Thus none of TG₁, TG₂ and TG₃ accepts any string, i.e. these TGs accept empty language. It may be noted that TG₁ and TG₂ are TGs but not FA, while TG₃ is both TG and FA as well.
It may be noted that every FA is a TG as well, but the converse may not be true, i.e. every TG may not be an FA.
Example
Consider the language L of strings, defined over Σ={a, b}, starting with b. The language L may be expressed by RE b(a + b)* , may be accepted by the following TG
a,b
Example
Consider the language L of strings, defined over Σ={a, b}, not ending in b. The language L may be expressed by RE Λ + (a + b) a* , may be accepted by the following TG
a,b
Example
Consider the Language L of strings, defined over Σ = {a, b}, containing double a. The language L may be expressed by the following regular expression (a+b) (aa) (a+b)** . This language may be accepted by the following TG
Example
Consider the language L of strings, defined over Σ={a, b}, having double a or double b. The language L can be expressed by RE (a+b) (aa + bb) (a+b)** .
The above language may also be expressed by the following TGs.
OR
OR
Note
In the above TG if the states are not labeled then it may not be considered to be a single TG.
⭐ Key Takeaways
A string is accepted by a TG if there exists at least one path from the initial state to a final state labeled with that string; the existence of other paths that reject the string is irrelevant. Not every TG is a Finite Automaton (FA), but every FA is a TG because TGs are a more general model allowing multiple paths and undefined transitions. A TG with no transitions or with transitions that never lead to a final state accepts the empty language. Different TGs (with different numbers of states and transition structures) can accept the same language, demonstrating the non-uniqueness of TGs for a given regular language.
🧠 Quick Revision Questions
- What is the acceptance criterion for a string in a Transition Graph (TG)?
- Can a TG accept the empty language? If so, give an example.
- Is it true that every TG is also a Finite Automaton (FA)? Justify your answer.
- Construct a TG that accepts the language of all strings over {a, b} that start with 'b'.
- How many different TGs can accept the same regular language?
📘 Lecture 9 — Theory of Automata (CS402) — Lecture N0. 9
📖 Overview: This lecture focuses on constructing Transition Graphs (TGs) for specific languages defined by regular expressions. It demonstrates how to design TGs for languages containing substrings, having specific start/end conditions, and even clump constraints. The lecture concludes by introducing the Generalized Transition Graph (GTG), a more powerful model where edges are labeled with regular expressions instead of single letters.
🗂️ Topics Covered
Examples of TGs accepting languages: containing "aaa" or "bbb", beginning and ending in different letters, beginning and ending in same letters, EVEN-EVEN language, strings where a’s occur in even clumps and end with three or more b’s. An example showing different paths traced by one string through a TG. The definition and concept of Generalized Transition Graphs (GTGs).
📝 Lecture Summary
Example (TG for language containing "aaa" or "bbb")
Consider the language L of strings, defined over Σ = {a, b}, having triple a or triple b. The language L may be expressed by RE (a+b)* (aaa + bbb) (a+b)*. This language may be accepted by the following TG.
- Diagram 1 (First TG design): A single start state (-) connected to a single final state (+) by an edge labeled
aaa, bbb. This means the string must contain either "aaa" or "bbb". - Diagram 2 (More detailed TG design): A start state (1-) that loops on
a,bbefore going to state (2+) on readingaaaorbbb. State (2+) then loops ona,b. This shows that the required substring can appear anywhere in the string.
Example (TG for strings beginning and ending in different letters)
Consider the language L of strings, defined over Σ = {a, b}, beginning and ending in different letters. The language L may be expressed by RE a(a + b)* b + b(a + b)* a. The language L may be accepted by the following TG.
- Diagram: A start state (1-) has two outgoing edges: one labeled
agoing to state (2), and one labeledbgoing to state (3). State (2) has a loop ona,band an edge labeledbto the final state (4+). State (3) has a loop ona,band an edge labeledato the final state (5+). This enforces the first and last letters to be different.
Example (TG for strings beginning and ending in same letters)
Consider the Language L of strings of length two or more, defined over Σ = {a, b}, beginning with and ending in same letters. The language L may be expressed by the following regular expression a(a + b)* a + b(a + b)* b. This language may be accepted by the following TG.
- Diagram: A start state (-) has an edge labeled
athat goes to a middle state, and an edge labeledbthat goes to a different middle state. Each middle state has a loop ona,b. The first middle state leads to a final state (+) on readinga, and the second middle state leads to the final state (+) on readingb. This ensures the string starts and ends with the same letter.
Example (TG for the EVEN-EVEN language)
Consider the EVEN-EVEN language, defined over Σ = {a, b}. As discussed earlier, the EVEN-EVEN language can be expressed by a regular expression (aa+bb+(ab+ba)(aa+bb)*(ab+ba))*. The language EVEN-EVEN may be accepted by the following TG.
- Diagram: A 4-state TG where the start state (-) is also the final state (+). State (1) has a loop on
aaandbb. State (2) has a loop onaaandbband is connected to states (3) and (4) viaabandba. This is a compact representation of the EVEN-EVEN language.
Example (TG for strings with a's in even clumps ending in three or more b's)
Consider the language L, defined over Σ={a, b}, in which a’s occur only in even clumps and that ends in three or more b’s. The language L can be expressed by its regular expression (aa)* b(b*+(aa(aa)*b)*) bb OR (aa)* b(b*+ ((aa)+b)*) bb. The language L may be accepted by the following TG.
- Diagram: A start state (-) has a loop on
aa. From there, an edge labeledbgoes to state (1). State (1) loops onbband has an edge labeledbto state (2). State (2) has an edge labeledbto the final state (+), which loops onaa. State (1) also has an edge labeledabto state (3), which has a loop onaaand an edge labeledbback to state (1).
Example (Different paths traced by one string)
Consider the following TG (a 5-state TG with states -, 1, 2, 3, 4, and +).
Diagram Description:
- Start state (-) has an edge labeled
ato state (4). - State (4) has edges:
abto state (3),bto state (+), and a loop onb. - Final state (+) has edges:
bbandato state (2), andabandbto state (3). - State (2) has edges:
bbto state (1),ato state (+). - State (1) has an edge
aato state (+). - State (3) has an edge
bbto state (2).
Consider the string abbbabbbabba. It may be observed that the above string traces the following three paths (using the states):
- (a) (b) (b) (b) (ab) (bb) (a) (bb) (a) → Path: (-) → (4) → (4) → (+) → (+) → (3) → (2) → (2) → (1) → (+)
- (a) (b) ((b)(b)) (ab) (bb) (a) (bb) (a) → Path: (-) → (4) → (+) → (+) → (+) → (3) → (2) → (2) → (1) → (+)
- (a) ((b) (b)) (b) (ab) (bb) (a) (bb) (a) → Path: (-) → (4) → (4) → (4) → (+) → (3) → (2) → (2) → (1) → (+)
Which shows that all these paths are successful (i.e., the path starting from an initial state and ending in a final state). Hence the string abbbabbbabba is accepted by the given TG.
💡 Why this matters: This example demonstrates that a single string can have multiple successful paths through a TG. This is a key property of nondeterminism in finite automata.
Generalized Transition Graphs (GTGs)
A generalized transition graph (GTG) is a collection of three things:
- Finite number of states, at least one of which is start state and some (maybe none) final states.
- Finite set of input letters (Σ) from which input strings are formed.
- Directed edges connecting some pair of states labeled with regular expression.
It may be noted that in GTG, the labels of transition edges are corresponding regular expressions.
🔑 Definition — Generalized Transition Graph (GTG): A graph consisting of a finite number of states (with at least one start state and some final states), a finite input alphabet Σ, and directed edges labeled with regular expressions over Σ.
⭐ Key Takeaways
In this lecture, you learned how to construct Transition Graphs (TGs) from specific regular expressions by mapping language constraints directly onto state transitions. The critical feature is that a single input string can have multiple successful paths through a nondeterministic TG, as demonstrated by the string abbbabbbabba. Finally, the Generalized Transition Graph (GTG) was introduced as a more powerful model where edges are labeled with entire regular expressions, not just single symbols, which will be essential for converting regular expressions into finite automata.
🧠 Quick Revision Questions
- How would you design a TG that accepts strings containing "aba" where the substring must appear exactly once?
- For the TG in the "different paths" example, can you find a string that has more than three successful paths?
- What is the formal difference between a standard TG and a Generalized Transition Graph (GTG)?
- Can a TG have a loop on a state that represents a complex regular expression?
- If a string has both a successful and an unsuccessful path in a TG, is the string accepted or rejected?
📘 Lecture 10 — Examples of GTGs, Nondeterminism, Kleene’s Theorem
📖 Overview: This lecture demonstrates how Generalized Transition Graphs (GTGs) can accept various languages defined by regular expressions. It also introduces the concept of nondeterminism and presents Kleene’s Theorem, which establishes the equivalence of Finite Automata, Transition Graphs, and Regular Expressions.
🗂️ Topics Covered
The lecture covers examples of GTGs accepting languages containing double letters (aa or bb), strings beginning and ending with the same letter, strings beginning and ending with different letters, and strings containing triple letters (aaa or bbb). It also explains nondeterminism in TGs and GTGs, states Kleene’s Theorem with its three parts, and provides the proof for Part I.
📝 Lecture Summary
Example — Language containing aa or bb
Consider the language L of strings, defined over Σ = {a,b}, containing double a or double b. The language L can be expressed by the following regular expression (a+b)* (aa + bb) (a+b)*. The language L may be accepted by the following GTG with a start state (-) leading to a + state via edges labeled a+b, and the + state having a loop of a+b and an edge back to the start labeled aa+bb.
Example — Language beginning with and ending in same letters
Consider the Language L of strings, defined over Σ = {a, b}, beginning with and ending in same letters. The language L may be expressed by the following regular expression (a+b)+ a(a + b)*a + b(a + b)*b. This language may be accepted by the following GTG with a start state (-) that has edges labeled a+ and b+ leading to the final state (+), along with additional paths for a(a+b)*a and b(a+b)*b.
Example — Language beginning and ending in different letters
Consider the language L of strings, defined over Σ = {a, b}, beginning and ending in different letters. The language L may be expressed by RE a(a + b)*b + b(a + b)*a. The language L may be accepted by the following GTG with edges labeled a(a+b)*b and b(a+b)*a between the start state (-) and final state (+). The language L may be accepted by the following GTG as well with alternative paths.
Example — Language having triple a or triple b
Consider the language L of strings, defined over Σ = {a, b}, having triple a or triple b. The language L may be expressed by RE (a+b)* (aaa + bbb) (a+b)*. This language may be accepted by the following GTG with a start state (-) having an edge labeled (a+b)*(aaa+bbb)(a+b)* to the final state (+). OR with a start state (-) having an edge labeled a+b to a + state which has a loop of a+b and an edge back to start labeled aaa+bbb.
Nondeterminism
TGs and GTGs provide certain relaxations i.e. there may exist more than one path for a certain string or there may not be any path for a certain string, this property creates nondeterminism and it can also help in differentiating TGs or GTGs from FAs. Hence an FA is also called a Deterministic Finite Automaton (DFA).
🔑 Definition — Nondeterminism: The property of a computational model where, for a given input, there may be multiple possible paths or no path at all, as opposed to deterministic models where each input leads to exactly one state.
Kleene’s Theorem
If a language can be expressed by FA or TG or RE then it can also be expressed by the other two as well. It may be noted that the theorem is proved by proving the following three parts:
Kleene’s Theorem Part I — If a language can be accepted by an FA then it can be accepted by a TG as well.
Kleene’s Theorem Part II — If a language can be accepted by a TG then it can be expressed by an RE as well.
Kleene’s Theorem Part III — If a language can be expressed by a RE then it can be accepted by an FA as well.
Proof (Kleene’s Theorem Part I)
Since every FA can be considered to be a TG as well, therefore there is nothing to prove.
💡 Why this matters: Kleene’s Theorem is the foundational result of automata theory, proving that all three models (FA, TG, RE) are equivalent in expressive power. This means we can freely convert between models to leverage the strengths of each for different tasks.
⭐ Key Takeaways
Kleene’s Theorem establishes that Finite Automata, Transition Graphs, and Regular Expressions are all equivalent in the languages they can represent. GTGs provide flexibility through nondeterminism, allowing multiple paths or no path for a string, which distinguishes them from deterministic FAs. The proof of Part I is trivial because every FA is inherently a TG. Regular expressions can be directly transformed into GTGs by placing the entire RE on a single edge between start and final states. The ability to represent languages with double letters, same/different beginning and ending letters, and triple letters demonstrates the practical application of GTGs.
🧠 Quick Revision Questions
- What are the three equivalent representations of regular languages according to Kleene’s Theorem?
- How is nondeterminism exhibited in TGs and GTGs but not in FAs?
- Why is the proof of Kleene’s Theorem Part I considered trivial?
- How would you construct a GTG for the language containing the substring "aba"?
- What is the relationship between a DFA and a TG, and why is a DFA considered a special case?
📘 Lecture 11 — Proof of Kleene’s Theorem Part II, Examples of TGs to REs
📖 Overview: This lecture presents the complete proof of Kleene’s theorem Part II by providing an algorithm that converts any Transition Graph (TG) into a Regular Expression (RE). It explains four systematic steps to transform a TG into a Generalized Transition Graph (GTG) with a single initial state connected to a single final state by one transition edge, whose label becomes the desired RE. Multiple examples illustrate each step and the overall conversion process.
🗂️ Topics Covered
The lecture covers the proof of Kleene’s theorem Part II using a step-by-step algorithm, including handling multiple start states, multiple final states, merging parallel transitions, and eliminating states through bypassing. It also demonstrates the conversion of TGs to REs through worked examples, including handling circuits at states and sequential state elimination.
📝 Lecture Summary
Proof (Kleene’s Theorem Part II)
To prove part II of the theorem, an algorithm consisting of different steps is explained showing how a Regular Expression (RE) can be obtained corresponding to a given Transition Graph (TG). For this purpose, the notion of TG is changed to that of Generalized Transition Graph (GTG) — where the labels of transitions are corresponding REs.
🔑 GTG (Generalized Transition Graph): A TG where transition labels are REs instead of single letters.
💡 Why this matters: This algorithm provides a mechanical method to find the language (as an RE) accepted by any TG, which is essential for automata theory proofs and practical pattern matching.
Step 1: Handling Multiple Start States
If a TG has more than one start states, then introduce a new start state connecting the new state to the old start states by transitions labeled by Λ and make the old start states the non-start states.
📌 Example: Given a TG with start state 1- and start state 2-, this step introduces a new start state (minus sign) connected to both states 1 and 2 by Λ transitions, and states 1 and 2 become non-start states.
Step 2: Handling Multiple Final States
If a TG has more than one final states, then introduce a new final state, connecting the old final states to the new final state by transitions labeled by Λ.
📌 Example (continuing from Step 1): Given a TG with final states 3+ and 4+, this step introduces a new final state (plus sign) connected from both states 3 and 4 by Λ transitions, and states 3 and 4 become non-final states.
Step 3: Merging Parallel Transitions
If a state has two (or more than one) incoming transition edges labeled by the corresponding REs, from the same state (including the possibility of loops at a state), then replace all these transition edges with a single transition edge labeled by the sum of corresponding REs.
🔑 Sum of REs: The RE formed by adding the individual REs with a plus (+) sign, representing alternation (union).
📌 Example: If state 3 has two incoming transitions from state 5 — one labeled r1 and another labeled r2 — these are replaced by a single transition labeled r1 + r2.
Generalization: For any finite number of transitions from the same source to the same target (including self-loops), all are replaced by a single transition labeled with the sum of all their REs.
Step 4: Bypass and State Elimination
If three states in a TG are connected in sequence, then eliminate the middle state and connect the first state with the third by a single transition (include the possibility of circuit as well) labeled by the RE which is the concatenation of corresponding two REs in the existing sequence.
🔑 Concatenation of REs: The RE formed by writing one RE followed by another, representing sequential composition.
📌 Example (simple): Given states 1 → 2 (labeled r1) and 2 → 3 (labeled r2), eliminating state 2 gives a direct transition from 1 to 3 labeled r1 r2.
📌 Example (with circuit at middle state): Given state 1 → 3 (labeled r1), state 3 has a self-loop (labeled r3), and state 3 → 5 (labeled r2). To eliminate state 3, connect state 1 to state 5 with label r1 (r3)* r2.
Formula for circuit elimination: r1 (r3)* r2
r1= path from first state to the state being eliminatedr3= loop (circuit) at the state being eliminatedr2= path from the eliminated state to the next state
Example — Complete TG to RE Conversion
Starting TG: A TG with start state 1-, final state 4+, and intermediate states 2, 3 with various transitions.
Step 1: Already has single start state (already processed).
Step 2: Introduce new final state +. Connect old final state 4 to new final state + with Λ transition.
Step 3: (Applied during elimination process)
Step 4:
- Eliminate state 2 and state 3 (sequence elimination)
- Eliminate state 1 (final reduction)
Final Result: The TG is reduced to a single transition from start state to final state labeled: (ab + ba)(aa + b)*(aaa + bba)
Thus the required RE = (ab + ba)(aa + b)*(aaa + bba)
⭐ Key Takeaways
The core algorithm for converting any TG to an RE involves four steps: (1) adding a new start state with Λ transitions to all old start states; (2) adding a new final state with Λ transitions from all old final states; (3) merging parallel edges from the same source to the same destination by summing their REs; and (4) eliminating intermediate states sequentially using the bypass rule r1(r3)*r2 when a circuit exists at the eliminated state. The final result is a GTG with one start state and one final state connected by a single transition whose label is the desired RE. This algorithm provides a constructive proof of Kleene’s theorem Part II — that every TG corresponds to some RE.
🧠 Quick Revision Questions
- What is the purpose of introducing a new start state in Step 1 of the algorithm?
- How do you handle multiple final states when converting a TG to an RE?
- What rule is used to replace multiple transition edges from the same source to the same target state?
- Write the formula for eliminating a state that has a circuit (loop), with incoming path
r1and outgoing pathr2. - What is the RE obtained for the example TG discussed at the end of the lecture?
📘 Lecture 12 — Examples of Writing REs to TGs, RE Corresponding to TG Accepting EVEN-EVEN Language, Kleene’s Theorem Part III (Method 1: Union of FAs), Examples of FAs Corresponding to Simple REs, Example of Kleene’s Theorem Part III (Method 1) Continued
📖 Overview: This lecture demonstrates how to convert Transition Graphs (TGs) into Regular Expressions (REs) through state elimination and reduction techniques, including a detailed example for the EVEN-EVEN language. It introduces Kleene’s Theorem Part III, which states that for every regular expression, there exists a Finite Automaton (FA), and explains Method 1 for constructing an FA corresponding to the union of two regular expressions using their respective FAs.
🗂️ Topics Covered
The lecture begins with a detailed example of converting a TG to an RE by reducing it to a single initial and single final state with a single transition edge, obtaining the RE (b+aa)b*+(a+bb)a*. It then covers converting a TG for the EVEN-EVEN language into the RE (aa+bb+(ab+ba)(aa+bb)*(ab+ba))*. The lecture states Kleene’s Theorem Part III and provides simple examples of FAs for single-letter languages. Finally, it explains Method 1 (Union of FAs) in detail, constructing an FA for the union of two regular expressions r₁ = (a+b)*b and r₂ = (a+b)*aa(a+b)*, resulting in a five-state FA and the combined RE.
📝 Lecture Summary
Example
The lecture begins with a TG that is first reduced by adding a single initial state (connected to the original initial state via a Λ edge) and a single final state (connected from the original final state via a Λ edge). The TG is then simplified step-by-step by eliminating states and combining transition edges using bypass and concatenation rules.
🔑 Definition — Elimination of a state: To eliminate a state, a new path (edge) is created directly from its predecessor to its successor, labeled with the concatenation of the incoming edge, the loop on the state (if any), and the outgoing edge.
📐 Formula: Edge from A to C = (Edge(A→B)) (Loop on B)* (Edge(B→C))
📌 Example: To eliminate state 1 from a TG, the path from the initial state to the state after 1 (e.g., state 3) is replaced by a single edge labeled with the concatenation of the edge from the start to state 1 and the edge from state 1 to state 3, considering any loops on state 1. Through multiple such reductions, the TG is ultimately transformed into a single edge from the initial to the final state, labeled with the RE (b+aa)b*+(a+bb)a* .
Example (EVEN-EVEN Language)
This example starts with a TG that accepts the EVEN-EVEN language (strings with an even number of a's and an even number of b's). The initial state is also a final state. To prepare for state elimination, an additional initial state and an additional final state are introduced, connected to the original state via Λ edges.
🔑 Definition — EVEN-EVEN language: The language of all strings over Σ = {a, b} where the total number of a's is even and the total number of b's is even.
📌 Example: The TG has two states. State 2 (the original state) is eliminated by applying the formula. The resulting TG has a single state (state 1) with a complex loop. The loop labels are simplified using algebraic laws of regular expressions (like (aa+bb)+ (ab+ba)(aa+bb)*(ab+ba)). After eliminating the final state 1, the resulting RE is (aa+bb+(ab+ba)(aa+bb)*(ab+ba))* .
💡 Why this matters: This RE is the canonical regular expression for the EVEN-EVEN language, a classic example in automata theory.
Kleene’s Theorem Part III
Statement: If the language can be expressed by a RE then there exists an FA accepting the language.
🔑 Definition — Kleene’s Theorem Part III: This is the converse of Part I and Part II. It ensures that any regular expression is computationally realizable by a deterministic finite automaton.
📌 Example 1: For the language defined over Σ = {a,b} consisting of only the single letter b , the FA has an initial state (x₁) that transitions to a final state (x₂) on reading 'b'. On reading 'a', it stays in x₁. x₂ is a dead state (or final state with a self-loop on a and b).
📌 Example 2: For the language consisting of only the null string Λ, the FA has a single state which is both initial and final. This state has no transitions.
Method1 (Union of two FAs)
This method builds an FA for the union (r₁ + r₂) by combining the FAs of r₁ and r₂. The new FA's states represent pairs of states from the two original FAs.
🔑 Definition — Product construction (Union): The union FA, FA₃, has states that are ordered pairs (zᵢ ≡ (xⱼ, yₖ)), where xⱼ is a state from FA₁ and yₖ is a state from FA₂. The start state is the pair of start states (x₁, y₁). A state in FA₃ is final if either its x-component is final in FA₁ or its y-component is final in FA₂ (or both).
📐 Formula: Transition ([x₁, y₁], a) = [Transition(FA₁, x₁, a), Transition(FA₂, y₁, a)]
📌 Example: Let r₁ = (a+b)*b (FA₁: starts at x₁, ends at x₂ on 'b') and r₂ = (a+b)*aa(a+b)* (FA₂: starts at y₁, ends at y₃ on 'aa'). The union FA (FA₃) is constructed.
- State z₁ = (x₁, y₁) → on 'a': (x₁, y₂) = z₂; on 'b': (x₂, y₁) = z₃
- State z₂ = (x₁, y₂) → on 'a': (x₁, y₃) = z₄; on 'b': (x₂, y₁) = z₃
- State z₃⁺ = (x₂, y₁) → on 'a': (x₁, y₂) = z₂; on 'b': (x₂, y₁) = z₃
- State z₄⁺ = (x₁, y₃) → on 'a': (x₁, y₃) = z₄; on 'b': (x₂, y₃) = z₅
- State z₅⁺ = (x₂, y₃) → on 'a': (x₁, y₃) = z₄; on 'b': (x₂, y₃) = z₅
The states z₃, z₄, z₅ are final because either x₂ or y₃ is final. The RE corresponding to this new FA is
(a+b)*b + (a+b)*aa(a+b)*.
⭐ Key Takeaways
- The state elimination method for converting a TG to an RE involves introducing single initial/final states and systematically removing internal states by bypassing them with new edges labeled with the concatenation of surrounding paths, using the Kleene star for loops.
- The EVEN-EVEN language has a concise regular expression:
(aa+bb+(ab+ba)(aa+bb)*(ab+ba))*, which is derived from its corresponding TG. - Kleene’s Theorem Part III proves the completeness of regular expressions: every regular expression can be realized by a finite automaton, forming a closed system.
- Method 1 (Union of FAs) is a practical construction where the states of the union FA are all possible pairs of states from the two component FAs.
- A state in the union FA is final if and only if at least one of its component states is final, which correctly accepts strings from either language.
🧠 Quick Revision Questions
- What is the final regular expression obtained from the first example TG (not the EVEN-EVEN one)?
- What is the regular expression for the EVEN-EVEN language as derived in this lecture?
- State Kleene’s Theorem Part III in your own words.
- In the union (product) construction for two FAs, how is a state of the combined FA determined to be a final state?
- For the union of r₁ = (a+b)*b and r₂ = (a+b)*aa(a+b)*, what are the final states in the resulting FA?
📘 Lecture 13 — Theory of Automata (CS402)
📖 Overview: This lecture continues the study of Kleene’s theorem, specifically Part III, which shows how to build a Finite Automaton (FA) for a given regular expression. It covers Method 1 (building an FA for union of regular expressions) with more examples, and introduces Method 2 for building an FA for the concatenation of two regular expressions. Understanding these methods is crucial for proving that all regular languages can be represented by FAs.
🗂️ Topics Covered
The lecture begins by reviewing an example of Kleene’s theorem part III (method 1) for union, noting the reduction in states from six to five. It then provides a complete example of building an FA for the union of two regular expressions, r₁ = (a+b)a and r₂ = (a+b)((a+b)(a+b)) or ((a+b)(a+b))(a+b), followed by another example for r₁ = ((a+b)(a+b)) and r₂ = (a+b)((a+b)(a+b)) or ((a+b)(a+b))(a+b)*. The main body introduces Method 2 (Concatenation of two FAs) and works through a detailed example for *r₁ = (a+b)b and *r₂ = (a+b)*aa(a+b)**.
📝 Lecture Summary
Examples of Kleene’s theorem part III (method 1) continued
This section continues the method for constructing an FA corresponding to the union (+) of two regular expressions, r₁ and r₂. The resulting FA, FA₃, accepts a string if it is accepted by FA₁ or by FA₂. The construction uses a transition table where each new state in FA₃ is a pair (xᵢ, yⱼ), representing a possible combination of a state from FA₁ and a state from FA₂. The initial state is (x₁, y₁). A state is a final state if either of its component states (xᵢ or yⱼ) is a final state in its respective FA. The transition for a letter is found by applying that letter to both component states.
It may be noted that the example discussed at the end of previous lecture, FA₁ contains two states while FA₂ contains three states. Hence the total number of possible combinations of states of FA₁ and FA₂, in sequence, will be six. For each combination the transitions for both a and b can be determined, but using the method in the example, number of states of FA₃ was reduced to five.
Example Let r₁ = (a+b)a and the corresponding FA₁ be: [FA₁ diagram with two states, x₁ and x₂, where x₁ has a loop on b to itself and a transition on a to x₂, and x₂ is a final state]. Also r₂ = (a+b)((a+b)(a+b)) or ((a+b)(a+b))(a+b)* and FA₂ be: [FA₂ diagram with two states, y₁ and y₂, where y₁ is initial and has a loop on a,b to itself and a transition on a,b to y₂, and y₂ is a final state and has a loop on a,b to itself]. FA corresponding to r₁+r₂ can be determined as:
| Old States | New States after reading | |
|---|---|---|
| a | b | |
| z₁-≡(x₁,y₁) | (x₂,y₂) ≡ z₂ | (x₁,y₂) ≡ z₃ |
| z₂+≡(x₂,y₂) | (x₂,y₁) ≡ z₄ | (x₁,y₁) ≡ z₁ |
| z₃+≡(x₁,y₂) | (x₂,y₁) ≡ z₄ | (x₁,y₁) ≡ z₁ |
| z₄+≡(x₂,y₁) | (x₂,y₂) ≡ z₂ | (x₁,y₂) ≡ z₃ |
The resulting FA is a diagram with states z₁, z₂, z₃, and z₄.
Example Let r₁ = ((a+b)(a+b)) and the corresponding FA₁ be: [FA₁ diagram with two states, x₁ and x₂, where x₁ is initial and final and has transitions on a,b to x₂, and x₂ has transitions on a,b to x₁]. Also r₂ = (a+b)((a+b)(a+b)) or ((a+b)(a+b))(a+b) and FA₂ be: [FA₂ diagram with two states, y₁ and y₂, where y₁ is initial and has a loop on a,b to itself and a transition on a,b to y₂, and y₂ is a final state and has a loop on a,b to itself]. FA corresponding to r₁+r₂ can be determined as:
| Old States | New States after reading | |
|---|---|---|
| a | b | |
| z₁±≡(x₁,y₁) | (x₂,y₂) ≡ z₂ | (x₂,y₂) ≡ z₂ |
| z₂+≡(x₂,y₂) | (x₁,y₁) ≡ z₁ | (x₁,y₁) ≡ z₁ |
Hence the required FA will be as follows: [FA diagram with two states, z₁ and z₂, both with transitions on a,b to each other. z₁ is initial and final, z₂ is final].
Method2 (Concatenation of two FAs)
Using the FAs corresponding to r₁ and r₂, an FA can be built, corresponding to r₁r₂. This method can be developed considering the following examples.
💡 Why this matters: For concatenation, the FA must transition from the language of the first expression to the language of the second. This is achieved by, upon entering a final state of the first FA, also considering the start state of the second FA as a possible next state.
Example Let *r₁ = (a+b)b defines L₁ and FA₁ be: [FA₁ with two states: x₁ (initial), x₂ (final). x₁ has a transition on a to itself and on b to x₂. x₂ has a transition on a to x₁]. And *r₂ = (a+b)aa(a+b) defines L₂ and FA₂ be: [FA₂ with three states: y₁ (initial), y₂, y₃ (final). y₁ has transitions on a to y₂ and on b to y₁. y₂ has transitions on a to y₃ and on b to y₁. y₃ has a loop on a,b to itself].
Let FA₃ be an FA corresponding to r₁r₂, then the initial state of FA₃ must correspond to the initial state of FA₁ and the final state of FA₃ must correspond to the final state of FA₂. Since the language corresponding to r₁r₂ is the concatenation of corresponding languages L₁ and L₂, consists of the strings obtained, concatenating the strings of L₁ to those of L₂, therefore the moment a final state of first FA is entered, the possibility of the initial state of second FA will be included as well.
Since, in general, FA₃ will be different from both FA₁ and FA₂, so the labels of the states of FA₃ may be supposed to be z₁, z₂, z₃, ..., where z₁ stands for the initial state. Since z₁ corresponds to the states x₁, so there will be two transitions separately for each letter read at z₁. It will give two possibilities of states which correspond to either z₁ or different from z₁. This process may be expressed in the following transition table for all possible states of FA₃.
| Old States | New States after reading | |
|---|---|---|
| a | b | |
| z₁-≡x₁ | x₁ ≡ z₁ | (x₂,y₁) ≡ z₂ |
| z₂≡(x₂,y₁) | (x₁,y₂) ≡ z₃ | (x₂,y₁) ≡ z₂ |
| z₃≡(x₁,y₂) | (x₁,y₃) ≡ z₄ | (x₂,y₁) ≡ z₂ |
| z₄+≡(x₁,y₃) | (x₁,y₃) ≡ z₄ | (x₂,y₁,y₃) ≡ z₅ |
| z₅+≡(x₂,y₁,y₃) | (x₁,y₂,y₃) ≡ z₆ | (x₂,y₁,y₃) ≡ z₅ |
| z₆+≡(x₁,y₂,y₃) | (x₁,y₃) ≡ z₄ | (x₂,y₁,y₃) ≡ z₅ |
Hence the required FA will be as follows: [FA diagram with states z₁, z₂, z₃, z₄, z₅, z₆ and their transitions for a and b as defined in the table].
Note: Another example is discussed in the next lecture.
⭐ Key Takeaways
The most critical point is understanding that Kleene’s theorem Part III provides constructive methods to build FAs for any regular expression. For union, you build a new FA by pairing states from the two original FAs; a state is final if at least one of its component states is final. For concatenation, you must allow the FA to transition from the first sub-language to the second; this is done by, whenever you enter a final state of the first FA, adding the start state of the second FA as a possible next state. The construction process is systematic, using a transition table, and can result in a minimized number of states by only including reachable state combinations. The final states of the concatenated FA are those that contain a final state of the second FA.
🧠 Quick Revision Questions
- When building an FA for the union of two regular expressions using Method 1, what does each new state represent?
- In a union FA, when is a state considered a final (accepting) state?
- What is the key idea in Method 2 for constructing an FA for the concatenation of two regular expressions?
- In the concatenation method, why might a state contain multiple states from the second FA (e.g., z₅ = (x₂, y₁, y₃))?
- Describe the state of the first FA that corresponds to the initial state of the concatenated FA, and describe the states of the second FA that correspond to the final states of the concatenated FA.
📘 Lecture 14 — Theory of Automata (CS402)
📖 Overview: This lecture continues the study of Kleene’s theorem Part III, which demonstrates how to construct Finite Automata (FAs) from Regular Expressions (REs). It covers three methods: building FA from REs using the union of FAs (Method 1), concatenation of FAs (Method 2), and closure of an FA (Method 3). Understanding these constructions is essential for proving the equivalence of regular expressions and finite automata.
🗂️ Topics Covered
Examples of Kleene’s theorem part III (method 1) continued, Kleene’s theorem part III (method 2: Concatenation of FAs), Examples of Kleene’s theorem part III (method 2: concatenation FAs) continued, Kleene’s theorem part III (method 3: closure of an FA), examples of Kleene’s theorem part III (method 3: Closure of an FA) continued.
📝 Lecture Summary
Examples of Kleene’s theorem part III (method 1) continued
The example demonstrates constructing an FA for the concatenation of two regular expressions. Let r₁ = ((a+b)(a+b))* and the corresponding FA₁ be given. Also, r₂ = (a+b)((a+b)(a+b))* or ((a+b)(a+b))*(a+b) and FA₂ be given. The FA corresponding to r₁r₂ is determined by taking the concatenation of FA₁ and FA₂.
The resulting FA is built by connecting the final state of FA₁ to the initial state of FA₂ using an ε-transition (or null transition). This ensures that strings from the language of r₁ are followed by strings from the language of r₂.
Method 2: (Concatenation of FAs)
Building an FA corresponding to the concatenation of two regular expressions, r₁r₂, uses the FAs corresponding to r₁ and r₂.
🔑 Definition — Kleene Part III Method 2: To construct an FA for r₁r₂, take FA₁ (for r₁) and FA₂ (for r₂), connect every final state of FA₁ to the initial state of FA₂ via an ε-transition, and make the initial state of FA₁ the new initial state and all final states of FA₂ the new final states.
📐 Formula: FA(r₁r₂) = ε-connection from FA₁ final states → FA₂ initial state
📌 Example: For r₁ = ((a+b)(a+b))* and r₂ = (a+b)((a+b)(a+b))*, we construct the new FA as shown in the lecture diagram. The old states are paired with new states after reading a and b:
- Old States z₁- ≡ (x₁, y₁): on a → (x₂, y₂) ≡ z₂; on b → (x₂, y₂) ≡ z₂
- Old States z₂+ ≡ (x₂, y₂): on a → (x₁, y₁) ≡ z₁; on b → (x₁, y₁) ≡ z₁
This yields a two-state FA that accepts the concatenated language.
Method 3: (Closure of an FA)
Building an FA corresponding to r*, using the FA corresponding to r. If the given FA already accepts the language expressed by the closure of a certain RE, then the given FA is the required FA. Otherwise, the method is developed considering examples.
🔑 Definition — Closure of an FA: Closure of an FA is the same as concatenation of an FA with itself, except that the initial state of the required FA is a final state as well. The initial state of the given FA corresponds to both the initial state of required FA and a non-final state of the required FA.
💡 Why this matters: The closure operation (Kleene star) allows an FA to accept zero or more repetitions of strings from the original language, making it a fundamental operation in regular language theory.
📌 Example 1: Let r = (a+b)b and the corresponding FA be given. Then the FA corresponding to r is determined using the state transition table:
- Old States z₁± ≡ x₁: on a → x₁ ≡ z₂; on b → (x₂, x₁) ≡ z₃
- Non-final z₂ ≡ x₁: on a → x₁ ≡ z₂; on b → (x₂, x₁) ≡ z₃
- z₃+ ≡ (x₂, x₁): on a → x₁ ≡ z₂; on b → (x₂, x₁) ≡ z₃
The resulting FA has z₁ as a final state (since initial state is also final for closure).
📌 Example 2: Let r = (a+b)aa(a+b) and the corresponding FA be given. Then the FA corresponding to r* is determined:
- Final z₁± ≡ y₁: on a → y₂ ≡ z₃; on b → y₁ ≡ z₂
- Non-final z₂ ≡ y₁: on a → y₂ ≡ z₃; on b → y₁ ≡ z₂
- z₃ ≡ y₂: on a → (y₃, y₁) ≡ z₄; on b → y₁ ≡ z₂
- z₄+ ≡ (y₃, y₁): on a → (y₃, y₁, y₂) ≡ z₅; on b → (y₃, y₁) ≡ z₄
- z₅+ ≡ (y₃, y₁, y₂): on a → (y₃, y₁, y₂) ≡ z₅; on b → (y₃, y₁) ≡ z₄
📌 Example 3: Consider an FA accepting the language of strings with 'b' as second letter. The FA has states y₁-, y₂, y₃+, y₄. Then the FA corresponding to r* is determined:
- z₁± ≡ y₁: on a → y₂ ≡ z₂; on b → y₂ ≡ z₂
- z₂ ≡ y₂: on a → y₄ ≡ z₃; on b → (y₃, y₁) ≡ z₄
- z₃ ≡ y₄: on a → y₄ ≡ z₃; on b → y₄ ≡ z₃
- z₄+ ≡ (y₃, y₁): on a → (y₃, y₁, y₂) ≡ z₅; on b → (y₃, y₁, y₂) ≡ z₅
- z₅+ ≡ (y₃, y₁, y₂): on a → (y₃, y₁, y₂, y₄) ≡ z₆; on b → (y₃, y₁, y₂) ≡ z₅
- z₆ ≡ (y₁, y₁, y₂, y₄): on a → (y₁, y₁, y₂, y₄) ≡ z₆; on b → (y₁, y₁, y₂, y₄) ≡ z₆
⭐ Key Takeaways
The most critical concepts from this lecture are: (1) Kleene's theorem Part III provides systematic methods to construct FAs from any regular expression using operations of union, concatenation, and closure on FAs. (2) For concatenation (Method 2), we connect each final state of the first FA to the initial state of the second FA via an ε-transition, making the initial state of the first FA the new start and all final states of the second FA the final states. (3) For closure (Method 3), we treat it as concatenation of the FA with itself, but crucially, the initial state of the resulting FA must also be a final state to allow zero repetitions. (4) The construction process uses state transition tables that combine old states (possibly pairs or sets of original states) with new state names. (5) These constructions are foundational for proving the equivalence of regular expressions and finite automata, and are essential for converting REs into practical automata implementations.
🧠 Quick Revision Questions
-
In Method 2 (concatenation of FAs), what is the role of ε-transitions and how are the initial and final states of the resulting FA determined?
-
How does the closure operation (Method 3) differ from concatenation, and why must the initial state be a final state in the closure FA?
-
For the FA accepting strings with 'b' as second letter (Example 3), trace the transition of string "aab" through the closure FA, showing each state visited.
-
Given an FA for r = (a+b)b, construct the transition table for the closure FA r and write the final state(s) that accept the empty string.
-
Explain why the number of states often increases when constructing the closure FA compared to the original FA, using the examples from the lecture.