Computation Theory Lec
Computation Theory Lec
• Regular Languages
• Non-Regular Languages
• Finite Automata
STRINGS AND LANGUAGES
Review
An alphabet is a nonempty, finite set of objects
(symbols).
►Σ is usually used to indicate alphabets.
►For instance, Σ 1 = a, b, c, d, e, f , Σ 2 = 0, 1
A string over Σ is any finite sequence of symbols
from Σ.
The empty string ε (sometimes λ(lambda)) is
the string consisting of no symbols.
REGULAR LANGUAGE
A regular language is a language that can be
expressed with a regular expression or a deterministic
or non-deterministic finite automata or state machine. A
language is a set of strings which are made up of
characters from a specified alphabet, or set of
symbols. Regular languages are a subset of the set of
all strings. Regular languages are used in parsing and
designing programming languages and are one of the
first concepts taught in computability courses. These are
useful for helping computer scientists to recognize
patterns in data and group certain computational
problems together ,once they do that, they can take
similar approaches to solve the problems grouped
together.
NON-REGULAR LANGUAGES
WHAT IS NON-REGULAR LANGUAGE
A non-regular language refers to a type of
formal language that cannot be recognized
by a finite automaton or expressed using a
regular expression. In the context of the
chomsky hierarchy of formal languages, non-
regular languages fall above regular
languages in complexity.
Non-Regular Languages
Key Points:
1.Regular Languages are the simplest type of languages
and can be recognized by finite automata. They can be
defined using regular expressions and are closed under
operations like union, intersection, and complementation.
2.Non-Regular Languages are more complex and
require more powerful computational models, such as
pushdown automata or Turing machines. They cannot
be represented by finite automata alone because they
require memory or a stack to keep track of certain
patterns, such as matching nested parentheses.
REGULAR OPERATIONS
Example
Let A = good, bad and B = boy, girl
► A B: good, bad, boy, girl .
► A B: goodboy, badboy, goodgirl, badgirl .
► A : ε, good, bad, goodgood,goodbad, badgood, badbad, . . . .
► B : ε, boy, girl, boyboy,boygirl, girlboy, girlgirl, . . . .
Kleene's theorem
►an FA stops
►when it reads all symbols on the tape
►Then, it gives an answer if the input
string is in the specific language:
►Answer “YES” if its last state is an
accept state
►Answer “NO” if its last state is not an
accept state
DETERMINISTIC FINITE AUTOMATA (INFORMAL)
► Regular languages can be defined using deterministic finite automata
(DFAs).
► Informally, a DFA M consists of a set of states q0, q1, . . . qn.
►q0 is called the start state.
►Some subset of q0, q1, . . . qn comprises the accept states.
► DFA M reads an input string w = w1 . . . wm, m 0:
► M operates in discrete steps.
► M occupies exactly one state at any given time.
►M begins in state q0.
► M reads w one character at a time, moving left to right.
► A transition function, together with the current state and character
determines M’s next state.
► If M reaches the end of w in an accept state, then M accepts string w.
Otherwise, it rejects it.
► The language L of M L(M) is the set of strings M accepts.
► A language is regular if and only if there is some DFA that accepts it.
STATE DIAGRAMS
RULE
While constructing a DFA,
•Always prefer to use the existing
path.
•Create a new path only when
there exists no path to go with
Why it is called
DETERMINISTIC FA
FA to be deterministic there are two rules :
1. Every state should response to all
of the inputs in the alphabet set.
2. q0 will never have the same
transition on the same input to a
different state .
Example 1:
Let L={abb,aabb,ababb,abbabb}
Example:4
NONDETERMINISTIC FINITE AUTOMATA (NFAS)
Solution
The language generated by this example will include all
strings in which the second-last bit is 1.
L= {10, 010, 000010, 11, 101011……..}
The following NFA automaton machine accepts all
strings where the second last bit is 1
NFA EXAMPLE 1:
Where:
•{q0, q1, q2} refers to the set of states
•{0,1} refers to the set of input alphabets
•δ refers to the transition function
•q0 refers to the initial state
•{q2} refers to the set of final states
Solution
The language generated by this example will include
all strings that must contain “double ‘1’ is
followed by single ‘0’.
L= {110, 0110, 1110, 10100110……..}
NFA Example 3 :