Formal Language: by Hossam Hawash
Formal Language: by Hossam Hawash
Formal Language
BY HOSSAM HAWASH
Alphabet 2
• Definition − The set ∑+ is the infinite set of all possible strings of all
possible lengths over ∑ excluding λ.
• Representation − ∑+ = ∑1 ∪ ∑2 ∪ ∑3 ∪…….
• ∑+ = ∑* − { λ }
• Example − If ∑ = { a, b } , ∑+ = { a, b, aa, ab, ba, bb,………..}
Language 7
(DFA)
In DFA, for each input symbol, one can determine the state to which
the machine will move. Hence, it is called Deterministic Automaton.
As it has a finite number of states, the machine is called
Deterministic Finite Machine or Deterministic Finite Automaton.
Formal Definition of a DFA 10
starting with 0.
solution
0
q0 q1
DFA with ∑ = {0, 1} accepts all 13
starting with 0.
solution
0,1
0
q0 q1
DFA with ∑ = {0, 1} accepts all 14
starting with 0.
solution
0,1
0
q0 q1
q2
DFA with ∑ = {0, 1}, L= {x|x is ending 15
with 0}.
solution
0
q0 q1
DFA with ∑ = {0, 1}, L= {x|x is ending 16
with 0}.
solution
0
0
q0 q1
DFA with ∑ = {0, 1}, L= {x|x is ending 17
with 0}.
solution
0
0
q0 q1
1
DFA with ∑ = {0, 1}, L= {x|x is ending 18
with 0}.
solution
1
0
0
q0 q1
1
DFA with ∑ = {0, 1}, L={x|x is string 19
1 0
q0 q1 q2
DFA with ∑ = {0, 1}, L={x|x is string 20
1 0
q0 q1 q2
DFA with ∑ = {0, 1}, L={x|x is string 21
1 0
1 0
q0 q1 q2
DFA with ∑ = {0, 1}, L={x|x is string 22
1 0
1 0
q0 q1 q2
1
DFA with ∑ = {0, 1}, L={x|x is string 23
1 0
1 0
q0 q1 q2
0
1
q3
DFA with ∑ = {0, 1}, L={ x | x start 24
with 110}
solution
0, 1
1 1 0
q0 q1 q2 q3
DFA with ∑ = {0, 1}, L={ x | x start 25
with 110}
solution
0, 1
1 1 0
q0 q1 q2 q3
0
q4
0, 1
DFA with ∑ = {0, 1}, L={ x | x start 26
with 110}
solution
0, 1
1 1 0
q0 q1 q2 q3
0 0
q4
0, 1
DFA with ∑ = {0, 1}, L={ x | x start 27
with 110}
solution
0, 1
1 1 0
q0 q1 q2 q3
0 0 1
q4
0, 1
DFA with ∑ = {0, 1}, L={ x | x end 28
with 1011}
solution
1 0 1 1
q0 q1 q2 q3 q4
DFA with ∑ = {0, 1}, L={ x | x end 29
with 1011}
solution
0
1 0 1 1
q0 q1 q2 q3 q4
DFA with ∑ = {0, 1}, L={ x | x end 30
with 1011}
solution
1
0
1 0 1 1
q0 q1 q2 q3 q4
DFA with ∑ = {0, 1}, L={ x | x end 31
with 1011}
solution
1
0
1 0 1 1
q0 q1 q2 q3 q4
0
DFA with ∑ = {0, 1}, L={ x | x end 32
with 1011}
solution
1
0 0
1 0 1 1
q0 q1 q2 q3 q4
0
DFA with ∑ = {0, 1}, L={ x | x end 33
with 1011}
solution
0
1
0 0
1 0 1 1
q0 q1 q2 q3 q4
0
DFA with ∑ = {0, 1}, L={ x | x end 34
with 1011}
solution
0
1
0 0
1 0 1 1
q0 q1 q2 q3 q4
1
0
35
Describe the language
accepted by the following
DfA.
Answer
L=(ab)*
L={x|x =(ab)^n n>=0}
36
Implementing
DFA in C++