0% found this document useful (0 votes)
41 views25 pages

Lecture 7

This document provides an overview of a lecture on finite state automata and related topics. It discusses sequential circuits and finite state machines, defines finite state automata and their components. It also covers language and grammars, regular expressions, non-deterministic finite state automata, and the concept of equivalent automata. Examples are provided of designing finite state automata to accept certain strings and the use of Backus-Naur form to define grammars. Reference books on discrete mathematics and related subjects are listed at the end.

Uploaded by

Jayaraj Joshi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views25 pages

Lecture 7

This document provides an overview of a lecture on finite state automata and related topics. It discusses sequential circuits and finite state machines, defines finite state automata and their components. It also covers language and grammars, regular expressions, non-deterministic finite state automata, and the concept of equivalent automata. Examples are provided of designing finite state automata to accept certain strings and the use of Backus-Naur form to define grammars. Reference books on discrete mathematics and related subjects are listed at the end.

Uploaded by

Jayaraj Joshi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 25

Discrete Structure

Lecture 7
Class Conducted by
Bibek Ropakheti
Associate Professor : Cosmos College of Management and Technology
Visiting Faculty : NCIT
July 2020
Chapter 2
Finite State Automata
Chapter Outline
• Sequential Circuits and Finite state Machine
• Finite State Automata
• Language and Grammars
• Non-deterministic Finite State Automata
• Language and Automata
• Regular Expression
Last Class
• Sequential Circuits and Finite state Machine
• Finite State Automata
Today
• Finite State Automata
• Language and Grammars
Finite State Automata: Design
• Design an FSA that accepts precisely those strings over {0,1} that:
1. 0’s only
2. Exactly four 0’s
3. More than three 0’s
4. Consecutive four 0’s
5. Exactly four 0’s that are also consecutive
6. Ends with 0
7. Ends with 011
8. Starts with 10
9. Contains 101
10. Every 0 followed by 1
Concept of Equivalent FSA
• If two FSA accept precisely the same strings, we say that the both
automata are equivalent
Exercise
• Pg. 579
• Q. 21-31
Finite State Automata
• Finite State Automata consists of:
• Input tape:
• Responsible for storing each character
of a input string
• Divided into square cells where each
cell is used to store a character of input
string
• Reading head:
• Used to scan the characters of the
input tape
• It reads one character at a time, either
in left to right direction or in right to
left direction
Finite State Automata
• Finite Control:
• Responsible for overall processing of
Finite State Automata
• Current state and next state obtained
during processing must be the states
defined by finite control
• While processing, initially the reading
head is placed either at the leftmost or
the rightmost cell of the input tape
Finite State Automata
• The reading head reads each
character of the input tape in a
particular direction
• During the process of reading, if
the string terminates i.e. reading
head reads epsilon and the finite
control gives any of the accepting
states as a next state, the string is
said to be accepted otherwise not
accepted
Types of FSA
• Deterministic Finite State • An NFA is different from a DFA
Automata (DFA/DFSA) from a point of view that in a
• Non-Deterministic Finite State DFA, the next function takes us
Automata (NFA/NDFA/NDFSA) to a uniquely defined state,
whereas in a NFA, the next state
function takes us to a set of
states
Languages and Grammar
• Merriam-Webster’s Dictionary describes language as “the words, their
pronunciation, and the methods of combining them used and understood
by a community”
• But this description of language is for natural languages
• The rules of natural languages are very complex and difficult to
characterize completely
• Hence, comes the Formal language
• Formal languages are used to model natural languages and to
communicate with the computers
• As it is possible to specify completely the rules by which certain formal
languages are constructed
Formal Language
• Let A be a finite set of alphabets.
• A (formal) language L over A is a subset of A∗, the set of all strings
over A.
• For example: Let A = {a, b}. The set L of all strings over A containing an
odd number of a’s is a language over A.
• One way to define a language is to give a list of rules that the
language is assumed to obey
Grammar
• A phrase-structure grammar (or, simply, grammar) G consists of
(a) A finite set N of nonterminal symbols
(b) A finite set T of terminal symbols where N ∩ T = ∅
(c) A finite subset P of [(N ∪ T)∗ − T∗] × (N ∪ T)∗, called the set of productions
(d) A starting symbol σ ∈ N.
Written as, G = (N,T,P,σ).
• A production (A, B) ∈ P is usually written A → B.
• Above definition (c) states that,
in the production A → B, A ∈ (N ∪ T)∗ − T∗ and B ∈ (N ∪ T)∗;
thus A must include at least one nonterminal symbol, whereas B can
consist of any combination of nonterminal and terminal symbols.
Grammar: Example
• Let
N = {σ, S}
T = {a, b}
P={σ →bσ, σ →aS, S→bS, S→b}.
• Then G = (N,T,P,σ) is a grammar.
• A language generated by G, written as L(G) consists of all strings over
T derivable from σ.
• The idea is to start with the starting symbol and then repeatedly use
productions until a string of terminal symbols is obtained.
Derivable, Directly Derivable and Derivation
• Let G = (N,T,P,σ) be a grammar.
If α → β is a production and xαy ∈ (N ∪T)∗, we say that xβy is directly
derivable from xαy and write, xαy ⇒ xβy
• If αi ∈ (N ∪ T)∗ for i = 1,...,n, and αi+1 is directly derivable from αi for
i = 1,..., n − 1, we say that αn is derivable from α1 and write, α1 ⇒ αn
• We call α1 ⇒α2 ⇒···⇒αn the derivation of αn (from α1).
By convention, any element of (N∪T)∗ is derivable from itself.
Example
• Let G be the grammar of Example above.
• The string abSbb is directly derivable from aSbb,
written aSbb ⇒ abSbb,
by using the production S → bS.
• The string bbab is derivable from σ , written σ ⇒ bbab
• The derivation is σ ⇒bσ ⇒bbσ ⇒bbaS ⇒bbab.
Example: (Continues)
• The only derivations from σ are,
σ ⇒ bσ ⇒ . . . ⇒ bnσ ⇒ bnaS ⇒ bnabS ⇒. . . ⇒ bnabm−1S ⇒bnabm
• Where, n ≥ 0, m≥1.
• Thus L(G) consists of the strings over {a,b} containing precisely one a
that end with b.
Backus Normal Form
• An alternative way to state the productions of a grammar is by using
Backus normal form (or Backus–Naur form or BNF)
• In BNF the nonterminal symbols typically begin with “<” and end with
“>”
• The production S → T is written as S ::= T
• Productions of the form, S::=T1, S::=T2, ..., S::=Tn , may be combined as
S::=T1 | T2 |… |Tn
• Why BNF?
Because Computer languages like FORTRAN, PASCAL, C++ are typically
specified in BNF.
Example: BNF
• A Grammar for Integers
• An integer is defined as a string consisting of an optional sign (+ or −) followed
by a string of digits (0 through 9).
• The following grammar generates all integers.
• < digit > : := 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
<sign> : := + | -
< unsigned integer > : := < digit >| < digit >< unsigned integer >
< signed integer > : := <sign> < unsigned integer>
< integer > : := < signed integer >|< unsigned integer >
Example
• Its equivalent is:
• N={sign, digit, unsigned integer, signed integer, integer}
• T={+, -, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
• σ= integer
• With above productions.
Reference Books
• Keneth Rosen, Discrete Mathematical Structures with Applications to
Computer Science, WCB/ McGraw Hill
• G. Birkhoff, T.C. Bartee, Modern Applied Algebra, CBS Publishers.
• R. Johnsonbaugh, Discrete Mathematics, Prentice Hall Inc.
• G.Chartand, B.R.Oller Mann, Applied and Algorithmic Graph Theory,
McGraw Hill
• Joe L. Mott, Abrahan Kandel, and Theodore P. Baker, Discrete
Mathematics for Computer Scientists and Mathematicians, Prentice-
Hall of India
Let us Discuss
Any Issues?
Thank You

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy