RAJALAKSHMI ENGINEERING COLLEGE
description
Transcript of RAJALAKSHMI ENGINEERING COLLEGE
04/22/23 1
RAJALAKSHMI ENGINEERING COLLEGE
04/22/23 2
UNIT- I
AUTOMATA
04/22/23 3
04/22/23 4
04/22/23 5
04/22/23 6
04/22/23 7
04/22/23 8
04/22/23 9
04/22/23 10
04/22/23 11
04/22/23 12
04/22/23 13
04/22/23 14
04/22/23 15
Finite Automata
04/22/23 16
04/22/23 17
States Open Closed Sensors Front – Someone on the Front pad Rear – Someone on the Rear pad Both – Someone on both the pads Neither – No one on either pad
04/22/23 18
04/22/23 19
04/22/23 20
04/22/23 21
04/22/23 22
04/22/23 23
04/22/23 24
04/22/23 25
04/22/23 26
04/22/23 27
04/22/23 28
04/22/23 29
04/22/23 30
04/22/23 31
04/22/23 32
04/22/23 33
04/22/23 34
04/22/23 35
04/22/23 36
04/22/23 37
04/22/23 38
04/22/23 39
04/22/23 40
04/22/23 41
UNIT - II
REGULAR EXPRESSIONS AND
LANGUAGES
04/22/23 42
04/22/23 43
04/22/23 44
04/22/23 45
04/22/23 46
04/22/23 47
04/22/23 48
04/22/23 49
04/22/23 50
04/22/23 51
04/22/23 52
04/22/23 53
04/22/23 54
04/22/23 55
04/22/23 56
04/22/23 57
04/22/23 58
04/22/23 59
04/22/23 60
04/22/23 61
04/22/23 62
04/22/23 63
04/22/23 64
04/22/23 65
04/22/23 66
04/22/23 67
04/22/23 68
04/22/23 69
04/22/23 70
04/22/23 71
04/22/23 72
04/22/23 73
04/22/23 74
04/22/23 75
04/22/23 76
04/22/23 77
04/22/23 78
04/22/23 79
04/22/23 80
Questions about Regular Languages
04/22/23 81
Question contd…
04/22/23 82
Singleton Languages are Regular
04/22/23 83
Finite Languages are regular
04/22/23 84
04/22/23 85
04/22/23 86
04/22/23 87
04/22/23 88
04/22/23 89
Closure Properties for Regular Languages
04/22/23 90
Myhill-Nerode Theorem
04/22/23 91
04/22/23 92
04/22/23 93
04/22/23 94
UNIT III
CONTEXT-FREE GRAMMAR AND
LANGUAGES
04/22/23 95
Context Free Grammars
04/22/23 96
Cont…
04/22/23 97
Cont…
04/22/23 98
Defining CFG
04/22/23 99
Notational conventions For CFGs
04/22/23 100
OTHER CFG EXAMPLES
04/22/23 101
Languages of CFG
04/22/23 102
Languages of CFG
04/22/23 103
Regular Languages and CFL
04/22/23 104
Translating FAs into CFG
04/22/23 105
Formalizing the Translation
04/22/23 106
Closure Properties of CFL
04/22/23 107
Proving CFLs closed under Union
04/22/23 108
IDEA
04/22/23 109
Formal Construction of Gu
04/22/23 110
Derivations
04/22/23 111
Sentential Form
04/22/23 112
Left Most and Right Most Derivation
04/22/23 113
Right-Linear Grammars
04/22/23 114
Ambiguous Grammars
04/22/23 115
Ambiguous Grammars
04/22/23 116
Pushdown Automata
Recall our study of regular languages. They were defined in terms of regular expressions (syntax). We then showed that FAs provide the computational power needed to process them.We would like to mimic this line of development for CFLs. We have a “syntactic” definition of CFLs in terms of CFGs. What kind of computing power is needed to “process” (i.e. recognize) CFLs?Do FAs suffice?
04/22/23 117
Cont…
04/22/23 118
Cont…
04/22/23 119
Example PDA for{0n1n|n≥0}
04/22/23 120
Formal Definition
04/22/23 121
Instantaneous Description
04/22/23 122
Language accepted by PDA
04/22/23 123
Language accepted by PDA
04/22/23 124
Language accepted by PDA
04/22/23 125
Equivalence of CFGs and PDAs
04/22/23 126
Cont…
04/22/23 127
Deterministic PDA
04/22/23 128
UNIT - IV
PROPERTIES OF
CONTEXT-FREE LANGUAGES
04/22/23 129
Chomsky Normal Form
04/22/23 130
Defining CNF
04/22/23 131
What is the Big Deal about CNF?
04/22/23 132
Cont…
04/22/23 133
Converting CFGs into CNF
04/22/23 134
Eliminating ε-Productions
04/22/23 135
Cont…
04/22/23 136
Cont…
04/22/23 137
Nullability
04/22/23 138
Generating an ε-Production-free CFGs
04/22/23 139
Converting CFGs into CNF
04/22/23 140
Eliminating Unit Productions
04/22/23 141
Cont…
04/22/23 142
U(G,A) and New Productions
04/22/23 143
Example
04/22/23 144
Cont…
04/22/23 145
Formal Construction
04/22/23 146
Eliminating Terminal Productions
04/22/23 147
Example
04/22/23 148
Formal Construction
04/22/23 149
Pumping Lemma For CFLs
04/22/23 150
Cont…
04/22/23 151
Derivation Trees
04/22/23 152
Defining Derivation Tree
04/22/23 153
Example
04/22/23 154
Derivation Trees and CNF
04/22/23 155
04/22/23 156
Pumping Lemma for CFL
04/22/23 157
Proving Languages Non Context Free using Pumping Lemma
04/22/23 158
Prove that L= {aNbNcN|N ≥0} is Not a CFL
04/22/23 159
Proof Cont…
04/22/23 160
Turing Machines
04/22/23 161
A Finite Automaton
04/22/23 162
A Pushdown Automaton
04/22/23 163
A Turing Machine
04/22/23 164
Cont..
04/22/23 165
Differences
04/22/23 166
Example
04/22/23 167
Cont…
04/22/23 168
Cont…
04/22/23 169
Cont…
04/22/23 170
Formal Definition
04/22/23 171
Cont..
04/22/23 172
Cont…
04/22/23 173
Cont…
04/22/23 174
Configurations
04/22/23 175
Cont…
04/22/23 176
More Configuration
04/22/23 177
Accepting a Language
04/22/23 178
Enumerable Languages
04/22/23 179
UNIT – V
UNDECIDABILITY
04/22/23 180
Enumerable Languages
04/22/23 181
Enumerable Languages
04/22/23 182
Example
04/22/23 183
Example
04/22/23 184
Example
04/22/23 185
Element Distinctness
04/22/23 186
Element Distinctness
04/22/23 187
Element Distinctness
04/22/23 188
Element Distinctness
04/22/23 189
Element Distinctness
04/22/23 190
Variants
04/22/23 191
Multitape Turing Machine
04/22/23 192
Equivalence
04/22/23 193
Simulation
04/22/23 194
Simulation
04/22/23 195
Non Deterministic Turing Machine
04/22/23 196
Decidability
04/22/23 197
Example
04/22/23 198
Theorem
04/22/23 199
Theorem
04/22/23 200
Theorem
04/22/23 201
Theorem
04/22/23 202
Halting Problem
04/22/23 203
Cont..
04/22/23 204
Cont..
04/22/23 205
Turing Machines are countable
04/22/23 206
Cont..
04/22/23 207
Post Correspondence Problem
04/22/23 208
Cont…
04/22/23 209
Cont...
04/22/23 210
Cont…
04/22/23 211
Cont…
04/22/23 212
Cont…
04/22/23 213
04/22/23 214
NP-complete Problem
04/22/23 215
04/22/23 216
04/22/23 217
Decision Problems
To keep things simple, we will mainly concern ourselves with decision problems. These problems only require a single bit output: ``yes'' and ``no''.
How would you solve the following decision problems?
Is this directed graph acyclic? Is there a spanning tree of this undirected graph with total weight less than w? Does this bipartite graph have a perfect (all nodes matched) matching? Does the pattern p appear as a substring in text t?
04/22/23 218
04/22/23 219
P
P is the set of decision problems that can be solved in worst-case polynomial time:
If the input is of size n, the running time must be O(nk). Note that k can depend on the problem class, but not the particular instance.
All the decision problems mentioned above are in P.
04/22/23 220
Nice Puzzle
The class NP (meaning non-deterministic polynomial time) is theset of problems that might appear in a puzzle magazine: ``Nicepuzzle.''
What makes these problems special is that they might be hard tosolve, but a short answer can always be printed in the back, and it is easy to see that the answer iscorrect once you see it.
Example... Does matrix A have an LU decomposition?
No guarantee if answer is ``no''.
04/22/23 221
04/22/23 222
NP
Technically speaking:
A problem is in NP if it has a short accepting certificate. An accepting certificate is something that we can use to quickly show that the answer is ``yes'' (if it is yes). Quickly means in polynomial time. Short means polynomial size.
This means that all problems in P are in NP (since we don't evenneed a certificate to quickly show the answer is ``yes'').
But other problems in NP may not be in P. Given an integer x, is it composite? How do we know this is in NP?
04/22/23 223
Good Guessing
Another way of thinking of NP is it is the set of problems that can solved efficiently by a really good guesser.
The guesser essentially picks the accepting certificate out of the air(Non-deterministic Polynomial time). It can then convince itself that it is correct using a polynomialtime algorithm. (Like a right-brain, left-brain sort of thing.)
Clearly this isn't a practically useful characterization: how could we build such a machine?
04/22/23 224
Exponential Upperbound
Another useful property of the class NP is that all NP problems canbe solved in exponential time (EXP).
This is because we can always list out all short certificates in exponential time and check all O(2nk) of them.
Thus, P is in NP, and NP is in EXP. Although we know that P isnot equal to EXP, it is possible that NP = P, or EXP, or neither. Frustrating!
04/22/23 225
NP-hardness
As we will see, some problems are at least as hard to solve as any problem in NP. We call such problems NP-hard.
How might we argue that problem X is at least as hard (to within a polynomial factor) as problem Y?
If X is at least as hard as Y, how would we expect an algorithm that is able to solve X to behave?
04/22/23 226
04/22/23 227
04/22/23 228
04/22/23 229
04/22/23 230
One of the central (and widely and intensively studied 30 years) problems of (theoretical) computer science is to prove that
(a) PNP (b) NP co-NP.
All evidence indicates that these conjectures are true. Disproving any of these two conjectures would not only be considered truly spectacular, but would also come as a tremendous surprise (with a variety of far-reaching counterintuitive consequences).
NP-complete: Collection Z of problems is NP-complete if (a) it is NP and (b) if polynomial-time algorithm existed for solving problems in Z, then P=NP.
P
NPco-NP
04/22/23 231
04/22/23 232
04/22/23 233
04/22/23 234
04/22/23 235
04/22/23 236
NP-Complete Problems
04/22/23 237
04/22/23 238
04/22/23 239
04/22/23 240
04/22/23 241
04/22/23 242