CSCI 3130 Formal languages and automata theory Tutorial
![CSCI 3130: Formal languages and automata theory Tutorial 1 Lee Chin Ho CSCI 3130: Formal languages and automata theory Tutorial 1 Lee Chin Ho](https://slidetodoc.com/presentation_image/284151320eb60d57d4226d3f169e0104/image-1.jpg)
![About me • Name: Chin • Office: SHB 117 • Office hour: Tuesday 11: About me • Name: Chin • Office: SHB 117 • Office hour: Tuesday 11:](https://slidetodoc.com/presentation_image/284151320eb60d57d4226d3f169e0104/image-2.jpg)
![Finite Automata • Finite Automata 1. Q - States 2. S - Alphabets 3. Finite Automata • Finite Automata 1. Q - States 2. S - Alphabets 3.](https://slidetodoc.com/presentation_image/284151320eb60d57d4226d3f169e0104/image-3.jpg)
![Deterministic Finite Automata • There must be a transition corresponding to each alphabet at Deterministic Finite Automata • There must be a transition corresponding to each alphabet at](https://slidetodoc.com/presentation_image/284151320eb60d57d4226d3f169e0104/image-4.jpg)
![Nondeterministic Finite Automata • Can be at multiple states at the same time • Nondeterministic Finite Automata • Can be at multiple states at the same time •](https://slidetodoc.com/presentation_image/284151320eb60d57d4226d3f169e0104/image-5.jpg)
![Regular Expression • The symbols Æ and are regular expressions • Every a in Regular Expression • The symbols Æ and are regular expressions • Every a in](https://slidetodoc.com/presentation_image/284151320eb60d57d4226d3f169e0104/image-6.jpg)
![Regular Languages • Languages that can be represented by a DFA / NFA / Regular Languages • Languages that can be represented by a DFA / NFA /](https://slidetodoc.com/presentation_image/284151320eb60d57d4226d3f169e0104/image-7.jpg)
![Checklist 1. Always pay attention to S 2. For DFA, out degree of each Checklist 1. Always pay attention to S 2. For DFA, out degree of each](https://slidetodoc.com/presentation_image/284151320eb60d57d4226d3f169e0104/image-8.jpg)
![Example in Lecture 1. q 2 is a “die” state 2. After a 1 Example in Lecture 1. q 2 is a “die” state 2. After a 1](https://slidetodoc.com/presentation_image/284151320eb60d57d4226d3f169e0104/image-9.jpg)
![Exercise S = {0, 1} L = {w: w is non-empty and the sum Exercise S = {0, 1} L = {w: w is non-empty and the sum](https://slidetodoc.com/presentation_image/284151320eb60d57d4226d3f169e0104/image-10.jpg)
![Idea • Need to keep track of the sum of digits • Arrive at Idea • Need to keep track of the sum of digits • Arrive at](https://slidetodoc.com/presentation_image/284151320eb60d57d4226d3f169e0104/image-11.jpg)
![Idea • • Need to keep track of the sum of digits Arrive at Idea • • Need to keep track of the sum of digits Arrive at](https://slidetodoc.com/presentation_image/284151320eb60d57d4226d3f169e0104/image-12.jpg)
![Answer • Handle the input 1 0 qs 0 q 0 0 1 q Answer • Handle the input 1 0 qs 0 q 0 0 1 q](https://slidetodoc.com/presentation_image/284151320eb60d57d4226d3f169e0104/image-13.jpg)
![Converting an NFA to a DFA • Eliminate q 0 for each state i Converting an NFA to a DFA • Eliminate q 0 for each state i](https://slidetodoc.com/presentation_image/284151320eb60d57d4226d3f169e0104/image-14.jpg)
![Converting an NFA to a DFA • Eliminate • Remember to consider the case Converting an NFA to a DFA • Eliminate • Remember to consider the case](https://slidetodoc.com/presentation_image/284151320eb60d57d4226d3f169e0104/image-15.jpg)
![Converting an NFA to a DFA • Every possible subsets of Q is a Converting an NFA to a DFA • Every possible subsets of Q is a](https://slidetodoc.com/presentation_image/284151320eb60d57d4226d3f169e0104/image-16.jpg)
![Converting an NFA to a DFA • Empty set ∅ = die S S Converting an NFA to a DFA • Empty set ∅ = die S S](https://slidetodoc.com/presentation_image/284151320eb60d57d4226d3f169e0104/image-17.jpg)
![Exercise 0 q 0 q 1 0 1 1 q 2 0, 1 Exercise 0 q 0 q 1 0 1 1 q 2 0, 1](https://slidetodoc.com/presentation_image/284151320eb60d57d4226d3f169e0104/image-18.jpg)
![Eliminating -transitions • • • q 0 can reach q 0 on 0 (q Eliminating -transitions • • • q 0 can reach q 0 on 0 (q](https://slidetodoc.com/presentation_image/284151320eb60d57d4226d3f169e0104/image-19.jpg)
![Eliminating -transitions • q 0 is the initial state • q 0 can reach Eliminating -transitions • q 0 is the initial state • q 0 can reach](https://slidetodoc.com/presentation_image/284151320eb60d57d4226d3f169e0104/image-20.jpg)
![Converting NFA to DFA 0 1 {q 0} {q 0, q 1} {q 2} Converting NFA to DFA 0 1 {q 0} {q 0, q 1} {q 2}](https://slidetodoc.com/presentation_image/284151320eb60d57d4226d3f169e0104/image-21.jpg)
![Converting NFA to DFA • Starting from initial state {q 0} 0 1 {q Converting NFA to DFA • Starting from initial state {q 0} 0 1 {q](https://slidetodoc.com/presentation_image/284151320eb60d57d4226d3f169e0104/image-22.jpg)
![Converting NFA to DFA • Check if every state has |S| outgoing transitions • Converting NFA to DFA • Check if every state has |S| outgoing transitions •](https://slidetodoc.com/presentation_image/284151320eb60d57d4226d3f169e0104/image-23.jpg)
![Converting NFA to DFA • Check if every state has |S| outgoing transitions • Converting NFA to DFA • Check if every state has |S| outgoing transitions •](https://slidetodoc.com/presentation_image/284151320eb60d57d4226d3f169e0104/image-24.jpg)
![Converting NFA to DFA • Check if every state has |S| outgoing transitions • Converting NFA to DFA • Check if every state has |S| outgoing transitions •](https://slidetodoc.com/presentation_image/284151320eb60d57d4226d3f169e0104/image-25.jpg)
![Converting NFA to DFA 0 • Check if every state has |S| outgoing transitions Converting NFA to DFA 0 • Check if every state has |S| outgoing transitions](https://slidetodoc.com/presentation_image/284151320eb60d57d4226d3f169e0104/image-26.jpg)
![Converting NFA to DFA • Done 0 q 0 q 1 1 q 2 Converting NFA to DFA • Done 0 q 0 q 1 1 q 2](https://slidetodoc.com/presentation_image/284151320eb60d57d4226d3f169e0104/image-27.jpg)
- Slides: 27
![CSCI 3130 Formal languages and automata theory Tutorial 1 Lee Chin Ho CSCI 3130: Formal languages and automata theory Tutorial 1 Lee Chin Ho](https://slidetodoc.com/presentation_image/284151320eb60d57d4226d3f169e0104/image-1.jpg)
CSCI 3130: Formal languages and automata theory Tutorial 1 Lee Chin Ho
![About me Name Chin Office SHB 117 Office hour Tuesday 11 About me • Name: Chin • Office: SHB 117 • Office hour: Tuesday 11:](https://slidetodoc.com/presentation_image/284151320eb60d57d4226d3f169e0104/image-2.jpg)
About me • Name: Chin • Office: SHB 117 • Office hour: Tuesday 11: 00 – 12: 00 • Homework 1 is due on next Thursday
![Finite Automata Finite Automata 1 Q States 2 S Alphabets 3 Finite Automata • Finite Automata 1. Q - States 2. S - Alphabets 3.](https://slidetodoc.com/presentation_image/284151320eb60d57d4226d3f169e0104/image-3.jpg)
Finite Automata • Finite Automata 1. Q - States 2. S - Alphabets 3. d - Transitions 4. q 0 - Initial state 5. F - Final state(s) / Accepting state(s)
![Deterministic Finite Automata There must be a transition corresponding to each alphabet at Deterministic Finite Automata • There must be a transition corresponding to each alphabet at](https://slidetodoc.com/presentation_image/284151320eb60d57d4226d3f169e0104/image-4.jpg)
Deterministic Finite Automata • There must be a transition corresponding to each alphabet at each state
![Nondeterministic Finite Automata Can be at multiple states at the same time Nondeterministic Finite Automata • Can be at multiple states at the same time •](https://slidetodoc.com/presentation_image/284151320eb60d57d4226d3f169e0104/image-5.jpg)
Nondeterministic Finite Automata • Can be at multiple states at the same time • Can go to multiple states on one alphabet • May have no transitions on an alphabet (die)
![Regular Expression The symbols Æ and are regular expressions Every a in Regular Expression • The symbols Æ and are regular expressions • Every a in](https://slidetodoc.com/presentation_image/284151320eb60d57d4226d3f169e0104/image-6.jpg)
Regular Expression • The symbols Æ and are regular expressions • Every a in S is a regular expression • If R and S are regular expressions, so are R+S, RS and R* • Remember for R*, * could be 0
![Regular Languages Languages that can be represented by a DFA NFA Regular Languages • Languages that can be represented by a DFA / NFA /](https://slidetodoc.com/presentation_image/284151320eb60d57d4226d3f169e0104/image-7.jpg)
Regular Languages • Languages that can be represented by a DFA / NFA / RE • DFA = NFA = RE • When asked if a language L is regular, represent L using a DFA / NFA / RE
![Checklist 1 Always pay attention to S 2 For DFA out degree of each Checklist 1. Always pay attention to S 2. For DFA, out degree of each](https://slidetodoc.com/presentation_image/284151320eb60d57d4226d3f169e0104/image-8.jpg)
Checklist 1. Always pay attention to S 2. For DFA, out degree of each state must be equal |S| e. g. S = {0, 1, 2}, L = {w: w begins with 01} 3. For NFA, pay attention to -transitions 4. Remember to specify the initial state 5. Make sure you have considered the input e. g. L = {w: w contains even number of 01}
![Example in Lecture 1 q 2 is a die state 2 After a 1 Example in Lecture 1. q 2 is a “die” state 2. After a 1](https://slidetodoc.com/presentation_image/284151320eb60d57d4226d3f169e0104/image-9.jpg)
Example in Lecture 1. q 2 is a “die” state 2. After a 1 has appeared, any 0 appears afterwards will die 3. 0*1* 0 q 0 1 1 q 1 0, 1 0 q 2 S = {0, 1}
![Exercise S 0 1 L w w is nonempty and the sum Exercise S = {0, 1} L = {w: w is non-empty and the sum](https://slidetodoc.com/presentation_image/284151320eb60d57d4226d3f169e0104/image-10.jpg)
Exercise S = {0, 1} L = {w: w is non-empty and the sum of the digits in w is divisible by 5}
![Idea Need to keep track of the sum of digits Arrive at Idea • Need to keep track of the sum of digits • Arrive at](https://slidetodoc.com/presentation_image/284151320eb60d57d4226d3f169e0104/image-11.jpg)
Idea • Need to keep track of the sum of digits • Arrive at the state qk when sum of digits = k 0 q 0 0 1 q 1 0 1 q 2 0 0 1 q 3 1 q 4 0 1 q 5 …
![Idea Need to keep track of the sum of digits Arrive at Idea • • Need to keep track of the sum of digits Arrive at](https://slidetodoc.com/presentation_image/284151320eb60d57d4226d3f169e0104/image-12.jpg)
Idea • • Need to keep track of the sum of digits Arrive at the state qk when sum of digits = k k divisible by 5 iff k mod 5 = 0 Keep track of the remainder instead 0 q 0 0 1 q 1 0 1 q 2 0 0 1 q 3 1 1 q 4
![Answer Handle the input 1 0 qs 0 q 0 0 1 q Answer • Handle the input 1 0 qs 0 q 0 0 1 q](https://slidetodoc.com/presentation_image/284151320eb60d57d4226d3f169e0104/image-13.jpg)
Answer • Handle the input 1 0 qs 0 q 0 0 1 q 1 0 1 q 2 0 0 1 q 3 1 1 q 4
![Converting an NFA to a DFA Eliminate q 0 for each state i Converting an NFA to a DFA • Eliminate q 0 for each state i](https://slidetodoc.com/presentation_image/284151320eb60d57d4226d3f169e0104/image-14.jpg)
Converting an NFA to a DFA • Eliminate q 0 for each state i q 0 for each alphabet x for each state j if i can reach j using one x and (s) add an edge from i to j with label x 0 0 q 1 q 2 0 q 0 1 q 1 q 2 1 q 0 q 1 1 q 2 1 q 3 1 q 0 q 1 1 1 q 2 q 3
![Converting an NFA to a DFA Eliminate Remember to consider the case Converting an NFA to a DFA • Eliminate • Remember to consider the case](https://slidetodoc.com/presentation_image/284151320eb60d57d4226d3f169e0104/image-15.jpg)
Converting an NFA to a DFA • Eliminate • Remember to consider the case when the initial state can reach accepting states on (s) q 0 q 1 1 1 q 2
![Converting an NFA to a DFA Every possible subsets of Q is a Converting an NFA to a DFA • Every possible subsets of Q is a](https://slidetodoc.com/presentation_image/284151320eb60d57d4226d3f169e0104/image-16.jpg)
Converting an NFA to a DFA • Every possible subsets of Q is a state in the DFA • Going to multiple states at the same time in the NFA = going to a subset of Q, which is now a state in the DFA q 0 1 q 1 1 q 2 {q 0} 1 {q 1, q 2}
![Converting an NFA to a DFA Empty set die S S Converting an NFA to a DFA • Empty set ∅ = die S S](https://slidetodoc.com/presentation_image/284151320eb60d57d4226d3f169e0104/image-17.jpg)
Converting an NFA to a DFA • Empty set ∅ = die S S ∅
![Exercise 0 q 0 q 1 0 1 1 q 2 0 1 Exercise 0 q 0 q 1 0 1 1 q 2 0, 1](https://slidetodoc.com/presentation_image/284151320eb60d57d4226d3f169e0104/image-18.jpg)
Exercise 0 q 0 q 1 0 1 1 q 2 0, 1
![Eliminating transitions q 0 can reach q 0 on 0 q Eliminating -transitions • • • q 0 can reach q 0 on 0 (q](https://slidetodoc.com/presentation_image/284151320eb60d57d4226d3f169e0104/image-19.jpg)
Eliminating -transitions • • • q 0 can reach q 0 on 0 (q 0 -> q 1 -> q 0) q 0 can reach q 1 on 0 (q 0 -> q 1) q 1 can reach q 0 on 0 (q 1 -> q 0) q 1 can reach q 1 on 0 (q 1 -> q 1) The rest of the transitions remain unchanged 0 q 0 q 1 0 1 1 q 2 0, 1 0 1 q 0, q 1 q 2 q 1, q 2
![Eliminating transitions q 0 is the initial state q 0 can reach Eliminating -transitions • q 0 is the initial state • q 0 can reach](https://slidetodoc.com/presentation_image/284151320eb60d57d4226d3f169e0104/image-20.jpg)
Eliminating -transitions • q 0 is the initial state • q 0 can reach an accepting state on (i. e. q 1) • therefore q 0 is also an accepting state 0 1 q 0, q 1 q 2 q 1 0 0 q 0 q 1, q 2 q 1 0 q 0 0 1 1 q 2 0 q 1 0 0, 1 1 1 q 2 0, 1
![Converting NFA to DFA 0 1 q 0 q 0 q 1 q 2 Converting NFA to DFA 0 1 {q 0} {q 0, q 1} {q 2}](https://slidetodoc.com/presentation_image/284151320eb60d57d4226d3f169e0104/image-21.jpg)
Converting NFA to DFA 0 1 {q 0} {q 0, q 1} {q 2} {q 1} {q 0, q 1} ∅ {q 2} {q 1, q 2} 0 0 0 q 1 0 1 1 q 2 0, 1
![Converting NFA to DFA Starting from initial state q 0 0 1 q Converting NFA to DFA • Starting from initial state {q 0} 0 1 {q](https://slidetodoc.com/presentation_image/284151320eb60d57d4226d3f169e0104/image-22.jpg)
Converting NFA to DFA • Starting from initial state {q 0} 0 1 {q 0} {q 0, q 1} {q 2} {q 1} {q 0, q 1} ∅ {q 2} {q 1, q 2} {q 0, q 1} 1 {q 2}
![Converting NFA to DFA Check if every state has S outgoing transitions Converting NFA to DFA • Check if every state has |S| outgoing transitions •](https://slidetodoc.com/presentation_image/284151320eb60d57d4226d3f169e0104/image-23.jpg)
Converting NFA to DFA • Check if every state has |S| outgoing transitions • No • “Fix” {q 2} and {q 0, q 1} • {q 0, q 1} goes to {q 0, q 1} ∪ {q 0, q 1} = {q 0, q 1} on 0 • {q 0, q 1} goes to {q 2} ∪ ∅ = {q 2} on 1 0 1 {q 0} {q 0, q 1} {q 2} {q 1} {q 0, q 1} ∅ {q 2} {q 1, q 2} 0 {q 0} {q 0, q 1} 1 0 1 {q 1} {q 2} 0 1 {q 1, q 2}
![Converting NFA to DFA Check if every state has S outgoing transitions Converting NFA to DFA • Check if every state has |S| outgoing transitions •](https://slidetodoc.com/presentation_image/284151320eb60d57d4226d3f169e0104/image-24.jpg)
Converting NFA to DFA • Check if every state has |S| outgoing transitions • No • “Fix” {q 1} and {q 1, q 2} • {q 1, q 2} goes to {q 0, q 1} ∪ {q 1} = {q 0, q 1} on 0 • {q 1, q 2} goes to ∅ ∪ {q 1, q 2} = {q 1, q 2} on 1 0 1 {q 0} {q 0, q 1} {q 2} {q 1} {q 0, q 1} ∅ {q 2} {q 1, q 2} 0 {q 0} {q 0, q 1} 1 1 0 0 {q 1} {q 2} 0 1 1 ∅ 0 {q 1, q 2} 1
![Converting NFA to DFA Check if every state has S outgoing transitions Converting NFA to DFA • Check if every state has |S| outgoing transitions •](https://slidetodoc.com/presentation_image/284151320eb60d57d4226d3f169e0104/image-25.jpg)
Converting NFA to DFA • Check if every state has |S| outgoing transitions • No • “Fix” ∅ • ∅ = die 0 1 {q 0} {q 0, q 1} {q 2} {q 1} {q 0, q 1} ∅ {q 2} {q 1, q 2} 0 {q 0} {q 0, q 1} 1 1 0 0 {q 1} {q 2} 0 1 1 0, 1 ∅ 0 {q 1, q 2} 1
![Converting NFA to DFA 0 Check if every state has S outgoing transitions Converting NFA to DFA 0 • Check if every state has |S| outgoing transitions](https://slidetodoc.com/presentation_image/284151320eb60d57d4226d3f169e0104/image-26.jpg)
Converting NFA to DFA 0 • Check if every state has |S| outgoing transitions • Yes • Accepting states = states that contain q 0 or q 1 0 0 q 1 0 1 1 0, 1 q 2 0 1 {q 0} {q 0, q 1} {q 2} {q 1} {q 0, q 1} ∅ {q 2} {q 1, q 2} 0 {q 0} {q 0, q 1} 1 1 0 0 {q 1} {q 2} 0 1 1 0, 1 ∅ 0 {q 1, q 2} 1
![Converting NFA to DFA Done 0 q 0 q 1 1 q 2 Converting NFA to DFA • Done 0 q 0 q 1 1 q 2](https://slidetodoc.com/presentation_image/284151320eb60d57d4226d3f169e0104/image-27.jpg)
Converting NFA to DFA • Done 0 q 0 q 1 1 q 2 {q 0} 0, 1 {q 0, q 1} 1 1 0 0 0 {q 1} {q 2} 0 1 1 0, 1 ∅ 0 {q 1, q 2} 1
Csci3130
Formal languages and automata theory tutorial
Formal languages and automata theory tutorial
Automata theory tutorial
Automata theory tutorial
Cyk algorithm
Csci 3130
Allcfg
Gtg stands for in automata
Csci3130
Itis 3130
Ece 3130
Ece 3130
Ece 3130
Cisc 3130
Difference between formal and informal language
The project will be completed next year formal or informal
Finite automata tutorial
Central concept of automata theory
Formal relational query languages
Find the id name dept_name
Grouping relational algebra
Generalized transition graph in automata
Bidirectional transducers in automata theory
Automata theory
Automata theory
All words
Difference between valid and invalid alphabets in automata