{ A, B, β¦, Z, a, b, β¦, z} is an English alphabet
String -=> Collection of Alphabet, sequence
A string over an alphabet β is a sequence of any number of symbols from β
Empty String -=> An empty string, denoted by Ι, is a string containing no symbol -=> Ι is a string over any alphabet
Length of String -=> -=> It is the number of symbols present in a string (Denoted by |S|)
Operations on Strings
Concatenation
The concatenation of strings x and y, denoted by x.y or xy, is a string z such that
automata.computation = automatacomputation
Substring
Let x and y be strings over an alphabet Ξ£. The string x is a substring of y if there exist strings w and z over Ξ£ such that y = w x z
Ξ΅ is a substring of every string
For every string x, x is a substring of x itself
Reversal
The reversal of the string x, denoted by xr, is a string such that if x is Ξ΅, then xr is Ξ΅ and other condition
β* -=> The set of strings created from any number (0 or 1 or β¦) of symbols in an alphabet β
β+ -=> The set of strings created from at least one symbol (1 or 2 or β¦) in an alphabet β
Language -=> Collection of String
Length of Language -=> Can be infinite
Operations on Languages
Complementation
Union
Intersection
Concatenation
Reversal
Closure
Kleeneβs closure/star
Kleeneβs closure/plus
Automata (Machine)
Mathematical Model/Machine to find of the given String is part of the Language
Not possible to find it in case of infinite Length by brute force method
Finite Automata (FA)
The finite automata or finite state machine is an abstract machine that has five elements or tuples. It has a set of states and rules for moving from one state to another but it depends upon the applied input symbol
Transition Diagram and Function
Language that FA accept are called Regular Language
Data Set -=> Regular expression to NFA > NFA to DFA > DFA Compression > Matching on DFA
Types
Finite Automata (FA)
Pushed Down Automata (PDA)
Linear Bound Automata (LBA)
Turing Machine (TM)
Power of β
β0 -=> Set of all Strings with length 0 = Ι or Ξ» -=> Null String -=> Contains identity element
β1 -=> Set of all Strings with length 1
β2 -=> β.β
β* -=> Kleene Closure -=> Set of all Strings of all length possible -=> Infinite Language = (a+b)* -=> Total 2n possibility
β+ -=> All Strings except β0 = β* - Ι
Grammar
A Grammar can be regarded as a device that enumerates the sentences of a Language
Give you the generated Language
A grammar G is defined as quadruple -=> G = {V, T, P, S}
Variable -=> Can repeat, In capital letter
Terminal -=> Terminate, In small letter
Production -=> Rules
Start -=> To start
Can check if the given String is part of that Language
Chomsky Hierarchy
Type 0 -=> Unrestricted Grammar (UG)
Recursively Languages (RE) -=> Turing Machine (TM)
Recursively Enumerable Languages (REC) -=> Halting Turing Machine (HTM)
Context Sensitive Language (CSL) -=> Linear Bound Automata (LBA)
Type 2 -=> Context Free Grammar (CFG)
Context Free Language (CFL) -=> Non-Deterministic Push Down Automata (NPDA)
Deterministic Context Free Language (DCFL) -=> Deterministic Push Down Automata (DPDA)
Power of NPDA > DPDA
Adding 1 Stack to FA creates PDA
Type 3 -=> Regular Grammar (RG)
Regular Language (REG) -=> Finite Automata (FA)
Power of DFA β‘ NFA
FA have limited memory
NFA is used to accept Infinite REG
x β y, x β V, y β T*V + T* or VT* + T* -=> Left linear or Right linear
Power -=> FA < DPDA < PDA < LBA < TM
DFA
Deterministic Finite Automata (DFA) = {Q, β, πΏ, qo, F} -=> Single choice of move after applying a Symbol
Q -=> Set of finite states
β -=> Set of Alphabet
πΏ -=> Transition -=> πΏ: Q x β β Q
If you apply any input symbol then where will it go
qo -=> Start
F -=> Set of finite final states -=> F β Q
Construct/Design DFA
Taking Complement of DFA -=> Make final β non-final & non-final β final states
Minimum States = Length of Minimum String + 1
NDFA
Non-deterministic Finite Automata (NFA) = {Q, β, qo, F, πΏ} -=> Multiple choice of move after applying a Symbol
Q -=> Set of finite states
β -=> Set of Alphabet
qo -=> Start
F -=> Set of finite final states -=> F β Q
πΏ -=> Transition -=> πΏ: Q x β β 2Q
Used to check weather a Regular language is accepted by a machine or not -=> NFA is easier to be implemented as compared to DFA
Thompson Construction -=> Regular expression to NFA
First we have to design its Regular expression
Conversion of NFA to DFA
Create Transition Table of NFA
Create Transition Table of DFA from NFA TT
Copy first row, then expand other states
Initial state same and final state will be all states that contains final state of NFA
If NFA contains n states then DFA will contain maximum of 2n states
Ι-NFA (Epsilon NFA)
NFA with epsilon transitions to NFA without epsilon transition -=> Eliminating Ι-moves
Ι-NFA = {Q, β, F, πΏ, qo}
Q -=> Finite set of states
β -=> Input Symbol (Alphabet)
F -=> Set of final states
πΏ -=> Transition Function -=> πΏ: Q x (β βͺ Ι) β 2Q
qo -=> Start state
Steps
Find all edge starting from S2
Duplicate all edges to S1 without changing edge labels
If S1 in initial state, make S2 initial also
If S2 in final state, make S1 final also
Remove dead state
Limitations of FSA
Limited Memory
Generally used for Regular Languages -=> Finite
Strings without Comparison
No comparison between Powers
Linear Power
Application of FSA
Word Processor Program
Digital Logic Design
Lexical Analyzer
Switching Circuit Design
Text Editors
Software for scanning large bodies of text such as Web pages to find occurrence of words, phases, patterns, etc
Software with finite states like Vending machines, Weigh machine, Traffic lights, Toll machines, etc
Game design like PacMan, Treasure Hunt, etc
Minimization of DFA
Make TT from Diagram if not given
Mark start and final states in TT
Remove unreachable states
Convert states into equivalent classes
Make one group of accepting states (final) and non-accepting states (non-final) -=> Ο0
Check and Separate every two symbols if the any outputs leads to a Symbol of different groups -=> Ο1
Check again like before, this time by referencing Ο1 -=> Ο2
Now the number of remaining groups represents new states, Create the Transition Diagram
Equivalence of NFA and DFA
Mealy & Moore
Moore Machine (Mo)
Mo = {Q, β, β, πΏ, Ξ», qo}
Q -=> Finite set of states
β -=> Input Symbol (Alphabet)
β -=> Output Symbol
πΏ -=> Transition Function -=> πΏ: Q x β β Q
Ξ» -=> Output function -=> Ξ»: Q β β
qo -=> Start state
If input is of length n, then output will be of length n+1
Transition Table
Current State
Next State
Output
Input = a | Input = b
qo
-
-
Mealy machine
Me = {Q, β, β, πΏ, Ξ», qo}
Q -=> Finite set of states
β -=> Input Alphabet -=> Format = input/output
β -=> Output Symbol
πΏ -=> Transition Function -=> πΏ: Q x β β Q
Ξ» -=> Output function -=> Ξ»: Q x β β β
qo -=> Start state
Output of state depends on input
If input is of length n, then output will be of length n
Transition Table
Current State
Next State
Output
Input = a | Input = b
State | Output | State | Output
qo
-
-
Difference between Mealy and Moore
Conversion
Moore to Mealy Conversion
m state & n output to maximum m state
From Transition Diagram
Write all the states
Write transition of each state same as Moore and output will be of state pointing towards
From Transition Table
Write all the columns from Moore TT except output column
Write output corresponding to each transition equal to the output of the state it represents
Mealy to Moore Conversion
m state & n output to maximum m x n state
From Transition Diagram
Start from starting state
Write transition corresponding to each input and write its output next to the state it is pointing towards
If output conflict than create a duplicate state with new output
Complete all input transition for all states, even the duplicates
Regular Expression
Method to represent a language (Regular Languages)
Let R be a Regular expression over β if R is
R = Ι -=> L(R) = {Ι}
R = Ξ¦ -=> L(R) = {}
R = a -=> L(R) = {a}
R1 βͺ R2 = Regular -=> Union
R1 . R2 = Regular -=> Concatenation
R* = Regular -=> Kleene Closure
If R is regular then (R) is also regular
FA to regular expression and regular expression to FA
Ardenβs Theorem -=> Find a regular expression of a Finite Automaton
Regular Expressions for Finite Languages
No String -=> L = {} -=> Ξ¦
Length 0 -=> L = {Ι} -=> Ι
Length 1 -=> L = {a, b} -=> (a + b)
Length 2 -=> L = {ab, ba, aa, bb} -=> (ab + ba + aa + bb) = (a + b)(a + b)
At most 1 -=> L = {Ι, a, b} -=> (Ι + a + b)
At most 2 -=> (Ι + a + b)(Ι + a + b)
Regular Expressions for Infinite Languages
Symbols Used
β -=> Single 0/1
β* -=> Any number of 0/1
1* -=> Any number of 1
β+ = β* - Ι = ββ*
All String having single "b" -=> a*ba*
All String having at least one "b" -=> (a+b)*b(a+b)*
Pattern matching and regular expressions
Regular grammar and FA
Pumping lemma for regular languages
To check weather the language is regular or not
It is a negative test
If Language fails PLT then it is not regular
If Language passes PLT then it is not decidable
If L is a infinite language then there exists some positive integer "n" (Positive length) such that any string W β L has length greater than equal to "n", |W| >= n then W can be divided into three parts, W = xyz satisfy following conditions
For each i >= 0, xyiz β L
|y| > 0
|xy| <= n
Closure Properties of Regular Languages
Reversal
Make initial state of M as final state of M
Final state of M became initial state of M
Reverse the direction of edges of M to make M
No change in loop and remove unnecessary states
Homomorphism
Substitution Function
Inverse Homomorphism
Homomorphism of Inverse Homomorphism of a Language is subset of original Language
Quotient Operation
Left Quotient (Cut Prefix)
Right Quotient (Cut Suffix)
INIT (Initial/Prefix)
Set of all Prefix of W β L
If making DFA for INIT then at last make all non-final states as final except traps
Infinite Union
Regular expression are not closed
Context Free Grammars
Context-Free Grammar (CFG)
CFG = {V, T, P, S}
Variable (V) -=> Finite set of variables (Non Terminal)