RAJALAKSHMI ENGINEERING COLLEGE

242
06/17/22 1 RAJALAKSHMI ENGINEERING COLLEGE

description

RAJALAKSHMI ENGINEERING COLLEGE. THEORY OF COMPUTATION. UNIT- I. AUTOMATA. Finite Automata. States Open Closed Sensors Front – Someone on the Front pad Rear – Someone on the Rear pad Both – Someone on both the pads - PowerPoint PPT Presentation

Transcript of RAJALAKSHMI ENGINEERING COLLEGE

Page 1: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 1

RAJALAKSHMI ENGINEERING COLLEGE

Page 2: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 2

UNIT- I

AUTOMATA

Page 3: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 3

Page 4: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 4

Page 5: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 5

Page 6: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 6

Page 7: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 7

Page 8: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 8

Page 9: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 9

Page 10: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 10

Page 11: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 11

Page 12: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 12

Page 13: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 13

Page 14: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 14

Page 15: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 15

Finite Automata

Page 16: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 16

Page 17: RAJALAKSHMI ENGINEERING COLLEGE

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

Page 18: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 18

Page 19: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 19

Page 20: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 20

Page 21: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 21

Page 22: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 22

Page 23: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 23

Page 24: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 24

Page 25: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 25

Page 26: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 26

Page 27: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 27

Page 28: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 28

Page 29: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 29

Page 30: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 30

Page 31: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 31

Page 32: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 32

Page 33: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 33

Page 34: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 34

Page 35: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 35

Page 36: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 36

Page 37: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 37

Page 38: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 38

Page 39: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 39

Page 40: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 40

Page 41: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 41

UNIT - II

REGULAR EXPRESSIONS AND

LANGUAGES

Page 42: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 42

Page 43: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 43

Page 44: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 44

Page 45: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 45

Page 46: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 46

Page 47: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 47

Page 48: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 48

Page 49: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 49

Page 50: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 50

Page 51: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 51

Page 52: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 52

Page 53: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 53

Page 54: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 54

Page 55: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 55

Page 56: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 56

Page 57: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 57

Page 58: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 58

Page 59: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 59

Page 60: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 60

Page 61: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 61

Page 62: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 62

Page 63: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 63

Page 64: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 64

Page 65: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 65

Page 66: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 66

Page 67: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 67

Page 68: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 68

Page 69: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 69

Page 70: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 70

Page 71: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 71

Page 72: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 72

Page 73: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 73

Page 74: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 74

Page 75: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 75

Page 76: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 76

Page 77: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 77

Page 78: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 78

Page 79: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 79

Page 80: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 80

Questions about Regular Languages

Page 81: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 81

Question contd…

Page 82: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 82

Singleton Languages are Regular

Page 83: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 83

Finite Languages are regular

Page 84: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 84

Page 85: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 85

Page 86: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 86

Page 87: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 87

Page 88: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 88

Page 89: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 89

Closure Properties for Regular Languages

Page 90: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 90

Myhill-Nerode Theorem

Page 91: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 91

Page 92: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 92

Page 93: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 93

Page 94: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 94

UNIT III

CONTEXT-FREE GRAMMAR AND

LANGUAGES

Page 95: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 95

Context Free Grammars

Page 96: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 96

Cont…

Page 97: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 97

Cont…

Page 98: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 98

Defining CFG

Page 99: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 99

Notational conventions For CFGs

Page 100: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 100

OTHER CFG EXAMPLES

Page 101: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 101

Languages of CFG

Page 102: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 102

Languages of CFG

Page 103: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 103

Regular Languages and CFL

Page 104: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 104

Translating FAs into CFG

Page 105: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 105

Formalizing the Translation

Page 106: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 106

Closure Properties of CFL

Page 107: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 107

Proving CFLs closed under Union

Page 108: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 108

IDEA

Page 109: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 109

Formal Construction of Gu

Page 110: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 110

Derivations

Page 111: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 111

Sentential Form

Page 112: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 112

Left Most and Right Most Derivation

Page 113: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 113

Right-Linear Grammars

Page 114: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 114

Ambiguous Grammars

Page 115: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 115

Ambiguous Grammars

Page 116: RAJALAKSHMI ENGINEERING COLLEGE

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?

Page 117: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 117

Cont…

Page 118: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 118

Cont…

Page 119: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 119

Example PDA for{0n1n|n≥0}

Page 120: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 120

Formal Definition

Page 121: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 121

Instantaneous Description

Page 122: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 122

Language accepted by PDA

Page 123: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 123

Language accepted by PDA

Page 124: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 124

Language accepted by PDA

Page 125: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 125

Equivalence of CFGs and PDAs

Page 126: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 126

Cont…

Page 127: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 127

Deterministic PDA

Page 128: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 128

UNIT - IV

PROPERTIES OF

CONTEXT-FREE LANGUAGES

Page 129: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 129

Chomsky Normal Form

Page 130: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 130

Defining CNF

Page 131: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 131

What is the Big Deal about CNF?

Page 132: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 132

Cont…

Page 133: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 133

Converting CFGs into CNF

Page 134: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 134

Eliminating ε-Productions

Page 135: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 135

Cont…

Page 136: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 136

Cont…

Page 137: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 137

Nullability

Page 138: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 138

Generating an ε-Production-free CFGs

Page 139: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 139

Converting CFGs into CNF

Page 140: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 140

Eliminating Unit Productions

Page 141: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 141

Cont…

Page 142: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 142

U(G,A) and New Productions

Page 143: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 143

Example

Page 144: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 144

Cont…

Page 145: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 145

Formal Construction

Page 146: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 146

Eliminating Terminal Productions

Page 147: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 147

Example

Page 148: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 148

Formal Construction

Page 149: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 149

Pumping Lemma For CFLs

Page 150: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 150

Cont…

Page 151: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 151

Derivation Trees

Page 152: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 152

Defining Derivation Tree

Page 153: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 153

Example

Page 154: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 154

Derivation Trees and CNF

Page 155: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 155

Page 156: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 156

Pumping Lemma for CFL

Page 157: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 157

Proving Languages Non Context Free using Pumping Lemma

Page 158: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 158

Prove that L= {aNbNcN|N ≥0} is Not a CFL

Page 159: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 159

Proof Cont…

Page 160: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 160

Turing Machines

Page 161: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 161

A Finite Automaton

Page 162: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 162

A Pushdown Automaton

Page 163: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 163

A Turing Machine

Page 164: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 164

Cont..

Page 165: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 165

Differences

Page 166: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 166

Example

Page 167: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 167

Cont…

Page 168: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 168

Cont…

Page 169: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 169

Cont…

Page 170: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 170

Formal Definition

Page 171: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 171

Cont..

Page 172: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 172

Cont…

Page 173: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 173

Cont…

Page 174: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 174

Configurations

Page 175: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 175

Cont…

Page 176: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 176

More Configuration

Page 177: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 177

Accepting a Language

Page 178: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 178

Enumerable Languages

Page 179: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 179

UNIT – V

UNDECIDABILITY

Page 180: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 180

Enumerable Languages

Page 181: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 181

Enumerable Languages

Page 182: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 182

Example

Page 183: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 183

Example

Page 184: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 184

Example

Page 185: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 185

Element Distinctness

Page 186: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 186

Element Distinctness

Page 187: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 187

Element Distinctness

Page 188: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 188

Element Distinctness

Page 189: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 189

Element Distinctness

Page 190: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 190

Variants

Page 191: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 191

Multitape Turing Machine

Page 192: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 192

Equivalence

Page 193: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 193

Simulation

Page 194: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 194

Simulation

Page 195: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 195

Non Deterministic Turing Machine

Page 196: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 196

Decidability

Page 197: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 197

Example

Page 198: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 198

Theorem

Page 199: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 199

Theorem

Page 200: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 200

Theorem

Page 201: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 201

Theorem

Page 202: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 202

Halting Problem

Page 203: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 203

Cont..

Page 204: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 204

Cont..

Page 205: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 205

Turing Machines are countable

Page 206: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 206

Cont..

Page 207: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 207

Post Correspondence Problem

Page 208: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 208

Cont…

Page 209: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 209

Cont...

Page 210: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 210

Cont…

Page 211: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 211

Cont…

Page 212: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 212

Cont…

Page 213: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 213

Page 214: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 214

NP-complete Problem

Page 215: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 215

Page 216: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 216

Page 217: RAJALAKSHMI ENGINEERING COLLEGE

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?

Page 218: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 218

Page 219: RAJALAKSHMI ENGINEERING COLLEGE

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.

Page 220: RAJALAKSHMI ENGINEERING COLLEGE

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''.

Page 221: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 221

Page 222: RAJALAKSHMI ENGINEERING COLLEGE

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?

Page 223: RAJALAKSHMI ENGINEERING COLLEGE

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?

Page 224: RAJALAKSHMI ENGINEERING COLLEGE

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!

Page 225: RAJALAKSHMI ENGINEERING COLLEGE

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?

Page 226: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 226

Page 227: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 227

Page 228: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 228

Page 229: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 229

Page 230: RAJALAKSHMI ENGINEERING COLLEGE

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

Page 231: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 231

Page 232: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 232

Page 233: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 233

Page 234: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 234

Page 235: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 235

Page 236: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 236

NP-Complete Problems

Page 237: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 237

Page 238: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 238

Page 239: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 239

Page 240: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 240

Page 241: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 241

Page 242: RAJALAKSHMI ENGINEERING COLLEGE

04/22/23 242