0% found this document useful (0 votes)
9 views

1th week introduction to theory of computation and DFA

Uploaded by

Arash
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

1th week introduction to theory of computation and DFA

Uploaded by

Arash
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 26

By: Mohammad Rahim Tahiri 1

Theory of Computation & Automata; collected by Tahiri 8/11/2023


▪ Introduction to theory of computation
▪ What are the layers of this subject
▪ Final state machine prerequisites
▪ Finite state machine
▪ DFA examples

Theory of Computation & Automata; collected by Tahiri 8/11/2023 2


▪ One of the most fundamental course of computer science.
▪ It will help you understand how people thought about computer science as a
science in past 50 years.
▪ It is mainly about what kind of things can you really compute mechanically, how fast
and how much space does it take to do so.
What kind of thing can we do mechanically?
e.g. Binary string –ends- with 0 or
Design a machine which accepts all valid java code or
Accepts all valid java code, and never goes into infinite loop

Theory of Computation & Automata; collected by Tahiri 8/11/2023 3


Yes

Input Think
No

Theory of Computation & Automata; collected by Tahiri 8/11/2023 4


▪ FSM (Finite State Machine)
▪ It is the simplest model of computation
Undecidable
▪ It has limited of memory
▪ It can perfume low level computations
Turing
▪ CFL (Context Free Language) Machine

▪ It more powerful than FSM


▪ Language does not mean programming language; it CFL
means set of Strings
▪ Turing machine
▪ It perform high calculation & computation designed
by Alon Turing 1940. Much FSM
▪ Much powerful than CFL & FSM.

▪ Undecidable
▪ The problem which can’t be solved mechanically

Theory of Computation & Automata; collected by Tahiri 8/11/2023 5


▪ Symbol: a, b, c, … or 0, 1, 2, 3, ….
▪ Alphabet: denoted by sigma Σ, it is collection of symbols
▪ Σ{a, b}, Σ{d, e, f, g}, Σ{0, 1, 2, 3,}

▪ String: a sequence of symbol is known as string


▪ A, b, 0, 1, aa, bb, ab, 01 …

▪ Language: set of strings is known as language


▪ Σ={0, 1} → consider this alphabet
▪ L1 = set of all strings of length 2. L1 = {00, 01, 10, 11}
▪ L2 = set of all string length 3. L2 = {000, 001, 010, 011, 100, 101, 110, 111}
▪ L3 = set of all string begin with 0. L3 = {0. 00, 01, 000, 001, 010, 011, 0000, …}
▪ L3 is infinite set where L1 & L2 are finite set .

Theory of Computation & Automata; collected by Tahiri 8/11/2023 6


▪ For example Σ={0, 1}, find the power of the sigma
▪ Σ0 set of all strings of length 0. Σ0 = {ε} ε → epsilon symbol
▪ Σ1 set of all strings of length 1. Σ1 = {0, 1}
▪ Σ2 set of all strings of length 2. Σ2 = {00, 01, 10, 11}
▪ Σ3 set of all string of length 3. Σ3 ={000, 001, 010, 011, 100, 101, 110, 111}
▪ ….
▪ Σn set of all string of length n

Theory of Computation & Automata; collected by Tahiri 8/11/2023 7


▪ Cardinality means number of elements in a set
▪ E.g. Σ3 = 8
▪ Σn = 2n If alphabet is two digit 0, 1
▪ Σ* = Σ0 ∪ Σ1 ∪ Σ2 ∪ Σ3 ∪ Σn
▪ Σ* = {ε} ∪{0, 1} ∪ {00, 01, 10, 11} ∪ {000, 001, 010, 011, 100, 101, 110, 111}… ∪ Σn
▪ Σ* Represent the set of all possible string of all length over {0, 1}
▪ And it is an infinite set

Theory of Computation & Automata; collected by Tahiri 8/11/2023 8


Finite
automata

FA with FA without
output output

Moore Mealy
DFA NFA Ε-NFA
machine machine

Theory of Computation & Automata; collected by Tahiri 8/11/2023 9


▪ DFA → (deterministic finite automata) and is a sub part of FSM
1

0 0 0
0

Theory of Computation & Automata; collected by Tahiri 8/11/2023 10


▪ Every DFA can be represent by 5 tuples and they are:
▪ (Q, Σ, q0, F, Δ)
▪ Q → set of all states
▪ Σ → inputs
▪ q0 → start state or initial state
▪ F → set of final state
▪ Δ → transition function which maps form Q * Σ → Q

Theory of Computation & Automata; collected by Tahiri 8/11/2023 11


1

0 0 0
0
▪ Q → set of all states. Q = {A, B, C, D}
1
▪ Σ → inputs. Σ= {0, 1}
▪ q0 → start state or initial state. q0 = A
1
▪ F → set of final state. F = {D}
▪ Δ → transition function which maps form Q * Σ → Q 0 1
A C B
B D A
C A D
D B C
Theory of Computation & Automata; collected by Tahiri 8/11/2023 12
▪ L1 = set of all strings that start with ‘0’
▪ L1 = {0, 00, 01, 000, 010, 011, 0000, …}
▪ L1 is an infinite set

Theory of Computation & Automata; collected by Tahiri 8/11/2023 13


0
0, 1

0, 1

Dead state or trap state

Theory of Computation & Automata; collected by Tahiri 8/11/2023 14


▪ Construct a DFA that accepts sets of all string over {0, 1} of length 2
▪ L = {00, 01, 10, 11}
▪ L is an finite set

Theory of Computation & Automata; collected by Tahiri 8/11/2023 15


0, 1 0, 1 0, 1
0, 1

Dead state or
trap state

Theory of Computation & Automata; collected by Tahiri 8/11/2023 16


▪ Construct a DFA that accepts any string over {a, b} which does not contain the
string ‘aabb’ in it
▪ A.S Σ= {a, b}

Theory of Computation & Automata; collected by Tahiri 8/11/2023 17


▪ Design a DFA with ∑ = {0, 1} accepts those string which starts with 1 and ends with
0.

Theory of Computation & Automata; collected by Tahiri 8/11/2023 18


In state q1, if we read 1, we will be in state q1, but if we read 0 at state q1, we will reach to state
q2 which is the final state. In state q2, if we read either 0 or 1, we will go to q2 state or q1 state
respectively. Note that if the input ends with 0, it will be in the final state.

Theory of Computation & Automata; collected by Tahiri 8/11/2023 19


▪ Design a DFA with ∑ = {0, 1} accepts the only input 101.

Theory of Computation & Automata; collected by Tahiri 8/11/2023 20


In the given solution, we can see that only input 101 will
be accepted. Hence, for input 101, there is no other path
shown for other input.

Theory of Computation & Automata; collected by Tahiri 8/11/2023 21


▪ Lest us to design a simpler problem.
▪ Lest us construct a DFA that accepts all string over {a, b} that contains the string
‘aabb’ in it

a a b b
b

a, b

a
b
Theory of Computation & Automata; collected by Tahiri 8/11/2023 22
▪ By flipping we means:
▪ Make the final state into non-final state and non-final state into final

a a b b
b

a, b

a
b
Theory of Computation & Automata; collected by Tahiri 8/11/2023 23
▪ How to figure out what a DFA recognizes?

0
1

0
1

Theory of Computation & Automata; collected by Tahiri 8/11/2023 24


▪ L = {accepts the string 01, or a string of at least one ‘1’ followed by a ‘0’}
▪ Check the following strings
1
▪ 001, 101, 011, 1101, 1100

0
1
0, 1

0, 1
X is the dead state
0
0, 1

0
1
Theory of Computation & Automata; collected by Tahiri 8/11/2023 25
THE END
Theory of Computation & Automata; collected by Tahiri 8/11/2023 26

You might also like