Lecture # 2 - Grammar & Language
Lecture # 2 - Grammar & Language
Theory Of Automata
By Fatima Aslam
1
Introduction to Grammar
2
Example
3
Solution
S ⇒ aSb
S ⇒ aaSbb
S ⇒ aabb
Therefore we have S* ⇒ aabb.
(i) Sentence in the language generated by
G = aabb. Sentential form = aaSbb.
(ii) The rule S → aSb is recursive.
4
Solution continued….
Some Applications
Software for designing and checking the
behavior of digital circuits
Lexical analyzer of a typical compiler
Software for scanning large bodies of text
(e.g., web pages) for pattern finding
Software for verifying systems of all types that
have a finite number of states (e.g., stock
market transaction, communication/network
protocol)
6
Let’s begin: Finite
Automata
1
1
0
Finite Automata – Formal Definition
8
Finite Automata : Examples
action
On/Off switch
state
Modeling recognition
of the word “then”
Grammars
Regular expressions
11
Deterministic Finite Automata -
Definition
12
What does a DFA do on reading an
input string?
Input: a word w in ∑*
Question: Is w acceptable by the DFA?
Steps:
Start at the “start state” q0
For every input symbol in the sequence w do
Compute the next state from the current state, given
the current input symbol in w and the transition
function
If after all symbols in w are consumed, the
current state is one of the accepting states (F)
then accept w;
Otherwise, reject w.
13
Example #1
14
Input: finite string
Output: Accept or Reject
Therefore 𝐴 is regular
17
consecutive 11
Alphabets 0,1
Acceptance String
011
11
0110
111
Rejection strings
010
18
Consecutive 11 {0,1} /bb {a,b} (3
states)
Start a {a,b} (ab,aa, a, aaa) (b, ba, bb)
(2 state)
End b {a,b} (2 states)
19