Theory of computation
Lecture 1: Automata and Regular languages
Adnane Saoud
Tuesday, September 5, 2023
1
About Me
• Engineering degree (École Mohammadia d’ingénieurs)
• Ph.D. in Control theory and Computer science at CentraleSupélec
and ENS Paris-Saclay, France (2019)
• Postdoc researcher at UC Santa Cruz, USA (2020)
• Postdoc researcher at UC Berkeley, USA (2021)
• Assistant Professor at CentraleSupélec (Sep 2021 – Aug 2022)
• Assistant Professor at UM6P-CS (Since Sept 2023)
Research interests: Control theory, machine learning, computer
science 2
What is computation
theory ?
3
Introduction
Computability Theory
- What is computable or not (problems that are solvable or not)
- Examples: program verification, mathematical truth
- Models of Computation:
Finite automata: used in text processing, compilers, control of systems
context-free grammar: used in programming languages and artificial
intelligence
Complexity Theory
- What is computable in practice?
- What makes some problems computationally
easy or hard
- Example: sorting and factoring problems
- P versus NP problem
4
About this course
5
Learning Objectives
The main learning objectives of the course are as follows:
• Formal Languages: Learn about formal languages, their syntax, and semantics. Describe and recognize
different types of formal languages such as regular languages and context-free languages.
• Automata Theory: Learn the fundamentals of automata theory such as finite automata, pushdown automata,
and Turing machines. Learn how to design these machines, analyze their behavior, and understand their
computational power.
• Computability Theory: Learn the concept of computability, the Church-Turing thesis, and the Halting
problem. Explore the limits of what is computationally solvable and understand undecidability.
• Complexity Theory: Learn about computational complexity tools such as time and space complexity
classes like P, NP. Be able to distinguish between problems that can be solved efficiently and those that are
NP-complete or harder.
• Problem Solving and Proof Techniques: Develop problem-solving skills by learning how to construct
proofs. Be able to prove whether a problem is decidable or undecidable.
• Practical Applications: While the primary focus is on theory, the course provides insights into practical
applications, demonstrating how theoretical concepts relate to real-world computational problems.
• Preparation for Advanced Studies: The course serves as a foundational course to pursue more advanced
studies in computer science, in areas related to formal methods, automata theory.
6
Structure of the Course
Four components:
1. Lectures
§ Tuesdays (and sometimes also Thursday)
2. Tutorials
§ Thursdays (First session)
Guided exercises sessions with the instructor
3. Labs
§ Thursdays (Second session)
Hands-on experience on computation theory tools
Labs will not be graded, but will help you to further understand the material presented in the lectures
Final Labs will be graded
4. Recitations
§ Thursdays (Second session)
Open exercises sessions for discussions and for answering questions
7
Course Logistics
• Canvas for Q&A and material
– You will receive an email shortly providing a link the Canvas
– All announcements will be posted there
– Also, lecture slides, tutorials and labs
– Please, participate and help each other!
8
Reading Material
• The book is publicly available in electronic form
– Pointers to chapters for every lecture (see the canvas)
9
Some Personal Notes J
• Please ask questions, participate in discussions on Canvas
• Play with software tools. Apply what you’ve learnt in theory
– This is the actual goal of the lab sessions and the recitations
• Give us your feedback!
10
Topics that will be
covered
11
Idea about the Schedule (Subject to Change)
1. Introduction, Finite Automata, Regular Expressions
2. Nondeterminism, Closure Properties, from Regular Expressions to
finite automata
3. The Regular Pumping Lemma, from Finite Automata to Regular
Expressions, Context free grammar
4. Pushdown Automata, equivalence between pushdown automata and
context free grammar
5. The Context free Pumping Lemma, Turing Machines
6. Turing machine Variants, the Church-Turing Thesis
12
Finite automata
13
Finite Automata
0 1
𝑀1 0,1
1
𝑞1 𝑞2 𝑞3
0
Input: finite string
Output: Accept or Reject
States: 𝑞1 𝑞2 𝑞3 Computation process: Begin at start state,
1 read input symbols, follow corresponding transitions,
Transitions:
Accept if end with accept state, Reject if not.
Start state:
Examples: 01101 → Accept
Accept states: 00101 → Reject
𝑀1 accepts exactly those strings in 𝐴 where
𝐴 = {𝑤| 𝑤 contains substring 11}.
𝐴 is the language of 𝑀1 and that 𝑀1 recognizes 𝐴 and that 𝐴 = 𝐿(𝑀1).
14
Finite Automata – Formal Definition
Definition: A finite automaton 𝑀 is a 5-tuple (𝑄, Σ, 𝛿, 𝑞! , 𝐹)
• 𝑄 finite set of states
• Σ finite set of alphabet symbols
a 𝑟
• 𝛿 transition function 𝛿: 𝑄×Σ → 𝑄 𝛿 (𝑞, 𝑎) = 𝑟 means 𝑞
• 𝑞! start state
• 𝐹 set of accept states 0
𝑀1 1
0,1
𝑞1 𝑞2 1 𝑞3
0
𝑀1 = (𝑄, Σ, 𝛿, 𝑞1, 𝐹) 𝛿=
Example: 0 1
𝑄 = {𝑞1, 𝑞2, 𝑞3}
𝑞1 𝑞1 𝑞2
Σ = {0, 1} 𝑞2 𝑞1 𝑞3
𝐹 = {𝑞3} 𝑞3 𝑞3 𝑞3
15
Regular languages
16
Finite Automata and Regular languages
Strings and languages
- A string is a finite sequence of symbols in Σ
- A language is a set of strings
- The empty string ε is the string of length 0
- The empty language ø is the set with no strings
Definition: 𝑀 accepts string 𝑤 = 𝑤1𝑤2 … 𝑤𝑛 each 𝑤𝑖 𝜖 Σ if there is a
sequence of states 𝑟0, 𝑟1, 𝑟2, , … , 𝑟𝑛 𝜖 𝑄 where:
- 𝑟0 = 𝑞0
- 𝑟𝑖 = 𝛿(𝑟!"# , 𝑤𝑖 ) for 1 ≤ 𝑖 ≤ 𝑛
- 𝑟𝑛 𝜖 𝐹
Recognizing languages
- 𝐿(𝑀) = {𝑤| 𝑀 accepts 𝑤} Definition: A language is regular if some
- 𝐿(𝑀) is the language of 𝑀 finite automaton recognizes it.
- 𝑀 recognizes 𝐿(𝑀) 17
Regular Languages – Examples
0
𝑀1 1
0,1
1
𝑞1 𝑞2 𝑞3
0
𝐿 𝑀# = {𝑤| 𝑤 contains substring 11} = 𝐴
Therefore 𝐴 is regular
Example of a non regular language:
Let 𝐶 = 𝑤 𝑤 has equal numbers of 0s and 1s}
𝐶 is not regular (will be proven in next lectures).
18
Regular Expressions
Regular operations. Let 𝐴, 𝐵 be languages:
- Union: 𝐴 ∪ 𝐵 = 𝑤 𝑤 ∈ 𝐴 or 𝑤 ∈ 𝐵}
- Concatenation: 𝐴 ∘ 𝐵 = 𝑥𝑦 𝑥 ∈ 𝐴 and 𝑦 ∈ 𝐵} = 𝐴𝐵
- Star: 𝐴∗ = 𝑥# … 𝑥% each 𝑥! ∈ 𝐴 for 𝑘 ≥ 0}
Note: ε ∈ 𝐴∗ always
Example. Let 𝐴 = {good, bad} and 𝐵 = {boy, girl}.
- 𝐴 ∪ 𝐵 = {good, bad, boy, girl}
- 𝐴 ∘ 𝐵 = 𝐴𝐵 = {goodboy, goodgirl, badboy, badgirl}
- 𝐴∗ = {ε, good, bad, goodgood, goodbad, badgood,
badbad, goodgoodgood, goodgoodbad, … }
19
Regular Expressions
Regular expressions
- Built from Σ, members Σ, ∅, ε [Atomic]
- By using ∪,∘,∗ [Composite]
Examples:
- 0∪1 ∗ = Σ ∗ gives all strings over Σ
- Σ ∗1 gives all strings that end with 1
- Σ ∗11Σ ∗ = all strings that contain 11 = 𝐿 𝑀#
Goal: Show that finite automata are equivalent to regular expressions
20
Closure properties
21
Closure Properties for Regular Languages
Theorem: If 𝐴#, 𝐴& are regular languages, so is 𝐴# ∪ 𝐴& (closure under ∪)
Proof: Let 𝑀# = (𝑄#, Σ, 𝛿# , 𝑞# , 𝐹# ) recognize 𝐴#
𝑀& = (𝑄& , Σ, 𝛿& , 𝑞& , 𝐹& ) recognize 𝐴&
Construct 𝑀 = (𝑄 , Σ , 𝛿 , 𝑞0, 𝐹 ) recognizing 𝐴# ∪ 𝐴&
𝑀 should accept input 𝑤 if either 𝑀# or 𝑀& accept 𝑤.
𝑀)
𝑞 𝑀
𝑀( ?
𝑟
22
Closure Properties for Regular Languages
Theorem: If 𝐴#, 𝐴& are regular languages, so is 𝐴# ∪ 𝐴& (closure under ∪)
Proof: Let 𝑀# = (𝑄#, Σ, 𝛿# , 𝑞'# , 𝐹# ) recognize 𝐴#
𝑀& = (𝑄& , Σ, 𝛿& , 𝑞'& , 𝐹& ) recognize 𝐴&
Construct 𝑀 = (𝑄 , Σ , 𝛿 , 𝑞0, 𝐹 ) recognizing 𝐴# ∪ 𝐴&
𝑀 should accept input 𝑤 if either 𝑀# or 𝑀& accept 𝑤.
Components of 𝑴:
𝑄 = 𝑄# ×𝑄&
= 𝑞# , 𝑞& 𝑞# ∈ 𝑄# and 𝑞& ∈ 𝑄& }
𝑞' = (𝑞'# , 𝑞'& ) Theorem: If 𝐴) , 𝐴( are regular
languages, so is 𝐴) ∩ 𝐴(
𝛿 𝑞, 𝑟 , 𝑎 = 𝛿# 𝑞, 𝑎 , 𝛿& 𝑟, 𝑎
𝐹 = 𝐹# ×𝐹& when we need this?
𝐹 = 𝐹# ×𝑄& ∪ 𝑄# ×𝐹&
23
Summary
24
Summary
1. Introduction, outline of the course
2. Finite Automata and regular languages: formal definition
3. Regular Operations and Regular Expressions
4. Theorem: Class of regular languages is closed under union and intersection
25