01 TOC
01 TOC
Introduction
SETS:
• A set is a group of objects represented as a unit.
• Sets may contain any type of object including numbers, symbols and
even other sets.
• The objects in a set are called its element or members.
Example: S={7,21,57}
Functions And Relations
• A function is an object that sets up an input-output relationship.
• A function takes an input and produces an output.
• In every function the same input produces the same output.
e.g.: f(a)=b
• The set of possible inputs to the function is called its domain.
• The outputs of a function come from a set called its range.
The notation for saying that f is a function with domain D and range R is
f:DR
In case of addition function for integers, the domain is the set of pairs of
integers Z×Z and the range is Z so, we write
add: Z×ZZ
Sequences and Tuples
• A sequence of object is a list of objects in some order.
Example:
(7,21,57) is a sequence
STRING
• A string is a finite sequence of symbols from Σ, e.g. aaaba.
• The length of a string s, denoted by |s| is the number of symbols in it,
eg. length of aaaba is 5.
• The empty string is the string of length zero, usually written as λ or ε
(epsilon)
• Σ ∗ denotes the set of all sequences of string that are composed of
zero or more symbols of Σ.
• Σ + denotes the set of all sequences of string that are composed of
one or more symbols of Σ.
• That is Σ ∗ = Σ + U Σ 0
A language is a subset of Σ ∗ .
REGULAR LANGUAGES
• We use several different computational models, depending on the
features we want to focus on.
• The simple model called the finite state machine or finite automaton
• Finite automata are good models for computers with an extremely
limited amount of memory.
Grammar :
• It is a finite set of formal rules for generating syntactically correct sentences or
meaningful correct sentences.
Constitute Of Grammar :
• Grammar is basically composed of two basic elements –
Terminal Symbols –
• Terminal symbols are those which are the components of the sentences generated using
a grammar and are represented using small case letter like a, b, c etc.
Non-Terminal Symbols –
• Non-Terminal Symbols are those symbols which take part in the generation of the
sentence but are not the component of the sentence.
• Non-Terminal Symbols are also called Auxiliary Symbols and Variables. These symbols are
represented using a capital letter like A, B, C, etc.
Grammar
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: 01011 → Accept
00101 → Reject
Accept states:
𝑀1 accepts exactly those strings in 𝐴 where
𝐴 = 𝑤 𝑤 contains substrings 11}.
Say that 𝐴 is the language of 𝑀1 and that 𝑀1 recognizes 𝐴 and that 𝐴 = 𝐿(𝑀1).
Formal Definition
0 1
The transition function 𝛿 is q1 q1 q2
q2 q1 q2
The state diagram of M and the formal description of M contain the same
information, only in different forms.
Binary number ends with 1
Σ={0,1}
set builder notation
0,1,00,01,10,11,………………
L={1,01,11,……}
={x1|x ∈{0,1}*}
Five-state machine M1
Three-state machine M2
Finite Automata – Computation
A+B AB 𝐴∗ 𝐴+
Either A or B A.B 𝐴0 𝐴1 𝐴2 …… 𝐴1 𝐴2 𝐴3 ………..
A followed by B λ/ε A AA ... A AA AAA ……
AB ×
Empty string/
BA ×
zero symbols/
zero length
𝐴∗ = 𝐴+U 𝐴0
3. a+ ε a+ ε
4. a. ε a
5. ε. ε ε
6. ε+ε ε
7. φ + ε ε
8. φ . ε φ
9. a.(b+c) ab+ac
A+B=B+A
Commutative A.B≠B.A
A+(B+C)=(A+B)+C
Associative A.(B.C)=(A.B).C
. over +
+ over .
Dominator R.φ= φ R+ Σ ∗ = Σ∗
Regular Expression
1. 𝑎0 = ε 11. φ∗ = ε+φ+φφ+ ⋯= ε
2. φ0 = ε 12. φ+ = φ
3. 𝑎1 = 𝑎 13. ε∗ = ε
4. φ1 = φ 14. ε+ = ε
5. ε0 = ε 15. 𝑎∗ = ε + 𝑎 + 𝑎𝑎 + 𝑎𝑎𝑎 + ⋯
6. ε1 = ε 16. 𝑎+ = 𝑎 + 𝑎𝑎 + 𝑎𝑎𝑎 + ⋯
7. 𝑎2 = 𝑎𝑎
8. 𝑏 3 = 𝑏𝑏𝑏
9. φ3 = Φφφ=φ
10. ε3 = εεε=ε
Regular Expression
Σ ∗ = (𝑎 + 𝑏)∗ = ε + 𝑎 + 𝑏 + 𝑎𝑎 + 𝑎𝑏 + 𝑏𝑎 + 𝑏𝑏+…………….
L={w|w 𝜖 {𝑎 + 𝑏}∗ } =set of all strings
𝑅 = (𝑎 + 𝑏)∗
L={w|w 𝜖 {𝑎 + 𝑏}∗ , |w|>0} set of all strings having more than zero length
𝑅 = (𝑎 + 𝑏)+
Question
• Which of the following does not satisfy commutative property in
regular expression?
1. OR
2. Concatenation
3. Both OR and Concatenation
4. None of these
Question
Which of the following is ODD?
1. 𝑎(𝑎 + 𝑏)∗
2. 𝑎𝑎∗ (𝑎 + 𝑏)∗
3. 𝑎∗ (𝑎∗ 𝑏∗ )∗
4. (𝑎𝑏∗ )+
Regular Expression
(𝑎 + 𝑏)∗ =
1. 𝑎∗
2. 𝑏∗ 10.(𝑎+ 𝑏+ )∗
3. 𝑎∗ 𝑏 ∗ 11.(𝑎+ 𝑏+ )+
4. 𝑏∗ 𝑎∗ 12.(𝑎∗ b)∗ 𝑎∗
5. (𝑎∗ 𝑏∗ )∗ 13.(𝑏∗ a)∗ 𝑏∗
6. (𝑏∗ 𝑎∗ )∗ 14.𝑏∗ (𝑎𝑏∗ )∗
7. 𝑏∗ + 𝑎 ∗ 15.𝑎∗ (𝑏𝑎∗ )∗
8. 𝑎∗ + 𝑏∗ 16.(𝑎∗ +𝑏)+
9. (𝑎∗ 𝑏∗ )+ 17.(𝑎 + 𝑏)+ +ε
Regular Expression
(𝑎 + 𝑏)∗ =
1. 𝑎∗
2. 𝑏∗ 10.(𝑎+ 𝑏+ )∗
3. 𝑎∗ 𝑏 ∗ 11.(𝑎+ 𝑏+ )+
4. 𝑏∗ 𝑎∗ 12.(𝑎∗ b)∗ 𝑎∗
5. (𝑎∗ 𝑏∗ )∗ 13.(𝑏∗ a)∗ 𝑏∗
6. (𝑏∗ 𝑎∗ )∗ 14.𝑏∗ (𝑎𝑏∗ )∗
7. 𝑏∗ + 𝑎 ∗ 15.𝑎∗ (𝑏𝑎∗ )∗
8. 𝑎∗ + 𝑏∗ 16.(𝑎∗ +𝑏)+
9. (𝑎∗ 𝑏∗ )+ 17.(𝑎 + 𝑏)+ +ε
Questions
Which one of the following regular expression represents the language:
set of all binary strings having two consecutive 0’s and two consecutive
1’s?
a) (0 + 1)∗ 0011(0 + 1)∗ +(0 + 1)∗ 1100(0 + 1)∗
a) (𝑎 + 𝑏)2
b) [(𝑎 + 𝑏)2 ]∗
c) [(𝑎 + 𝑏)∗ ]2
d) None of the above
Finite Automata
• NFA
• DFA