MELJUN CORTES Automata Theory (Automata20)

21
CSC 3130: Automata theory and formal languages Efficient computation MELJUN P. CORTES, MBA,MPA,BSCS,ACS MELJUN P. CORTES, MBA,MPA,BSCS,ACS MELJUN CORTES MELJUN CORTES

description

MELJUN CORTES Automata Theory (Automata20)

Transcript of MELJUN CORTES Automata Theory (Automata20)

Page 1: MELJUN CORTES Automata Theory (Automata20)

CSC 3130: Automata theory and formal languages

Efficient computation

MELJUN P. CORTES, MBA,MPA,BSCS,ACSMELJUN P. CORTES, MBA,MPA,BSCS,ACS

MELJUN CORTESMELJUN CORTES

Page 2: MELJUN CORTES Automata Theory (Automata20)

Why do we care about undecidability?

decidableundecidable

TM M accepts input w TM M accepts all inputsCFG G is ambiguous

Post Correspondence Problem

... pretty much everything else

anything you can writea computer program for

Is P a valid java program?

Can you pair up people

so that every pair is happy?

Can you get from point A

to point B in 100 steps?

Can you schedule final exams

so that there are no conflicts?L = {0n1n: n > 0}

Page 3: MELJUN CORTES Automata Theory (Automata20)

Decidable problems

L = {0n1n: n > 0}

On input x:n := |x|if n is odd rejectfor i := 0 to n/2: if xi ≠ 0 or xn-i ≠ 1 rejectotherwise accept

Is P a valid java program?

Can you get from point A to point B in 100 steps?

Option 1:Try all derivations

Option 2:CYK algorithmOption 3:LR(1) algorithm

8

610 14

14

3

3

9

8 4

25

5

9

AB

For all paths out of point A of length at most 100: Try this path If path reaches B, acceptOtherwise, reject

Page 4: MELJUN CORTES Automata Theory (Automata20)

Scheduling

Can you schedule final examsso that there are no conflicts?

Say we have n exams, k slots (maybe n = 200, k = 10)

Exams → vertices

Slots → colors

Conflicts → edges

CSC 3230 CSC 2110

CSC 3160CSC 3130

...

Task: Assign one of k colors to the verticesso that no edge has both endpoints of same color

Page 5: MELJUN CORTES Automata Theory (Automata20)

Scheduling algorithm

For every possible assignment of colors to vertices: Try this assignment If every edge has endpoints of different colors, acceptIf all colorings failed, reject

Task: Assign one of k colors to the verticesso that no edge has both endpoints of same color

CSC 3230 CSC 2110

CSC 3160CSC 3130

...

Page 6: MELJUN CORTES Automata Theory (Automata20)

Matching

Can you pair up people so that every pair is happy?

People → vertices

Happy together → edges

Pairing → matching

For every possible pairing: If each pair is happy, acceptIf all pairings failed, reject

Page 7: MELJUN CORTES Automata Theory (Automata20)

Shades of decidability

Is P a valid java program?

Can you pair up people

so that every pair is happy?

Can you get from point A

to point B in 100 steps?

Can you schedule final exams

so that there are no conflicts?L = {0n1n: n > 0}

Sure, we can write a computer program...

...but what happens when we run it?

Page 8: MELJUN CORTES Automata Theory (Automata20)

How fast?

L = {0n1n: n > 0}

On input x:n := |x|if n is odd rejectfor i := 0 to n/2: if xi ≠ 0 or xn-i ≠ 1 rejectotherwise accept

Is P a valid java program?

Can you get from point A to point B in 100 steps?

Option 1:Try all derivations

Option 2:CYK algorithmOption 3:LR(1) algorithm

8

610 14

14

3

3

9

8 4

25

5

9

AB

For all paths out of point A of length at most 100: Try this path If path reaches B, acceptOtherwise, reject

Page 9: MELJUN CORTES Automata Theory (Automata20)

How fast?

the lifetime of the universe

P = 100 line java program Is P a valid java program?

Option 1:Try all derivations

Option 2:CYK algorithm

Option 3:LR(1) algorithm

1 week

a few milliseconds

very inefficient efficient?

Page 10: MELJUN CORTES Automata Theory (Automata20)

Finding paths

Can you get from point A to point B in 1000 steps?

8

610 14

14

3

3

9

8 4

25

5

9

AB

For all paths out of point A of length at most 1000: Try this path If path reaches B, acceptOtherwise, reject

Is there a better wayto do this?

Yes! Dijkstra’s algorithm

Edsger Dijkstra (1930-2002)

Page 11: MELJUN CORTES Automata Theory (Automata20)

Matching

For every possible pairing: If each pair is happy, acceptIf all pairings failed, reject

Can we do better?

Yes! Edmonds’ algorithm

Jack Edmonds

Page 12: MELJUN CORTES Automata Theory (Automata20)

Scheduling algorithm

For every possible assignment of colors to vertices: Try this assignment If every edge has endpoints of different colors, acceptIf all colorings failed, reject

Task: Assign one of k colors to the verticesso that no edge has both endpoints of same color

CSC 3230 CSC 2110

CSC 3160CSC 3130

100 vertices, 10 colors

10100 assignmentsCan we do better?

Page 13: MELJUN CORTES Automata Theory (Automata20)

Some history

first electronic computer

UNIVAC

1950s

integrated circuits

Page 14: MELJUN CORTES Automata Theory (Automata20)

The need for optimization

routing problemshow to route calls throughthe phone network?

packing problemshow many trucks do you need to fit all the boxes?

Page 15: MELJUN CORTES Automata Theory (Automata20)

The need for optimization

scheduling problemshow do you schedule jobsto complete themas soon as possible?

constraint satisfactioncan you satisfy a systemof local constraints?

30 min

40 min

45 min

50 min

50 min

0 min

Page 16: MELJUN CORTES Automata Theory (Automata20)

Fast algorithms

shortest paths1956

matchings1965

and a few more…

Page 17: MELJUN CORTES Automata Theory (Automata20)

Proving theorems

Kurt Gödel

J. von Neumann

Princeton, 20 March 1956Dear Mr. von Neumann:With the greatest sorrow I have learned of your illness. […]Since you now, as I hear, are feeling stronger, I would like to allow myself to write you about a mathematical problem: […] This would have consequences of the greatest importance. It would obviously mean that in spite of the undecidability of the Entscheidungsproblem, the mental work of a mathematician concerning Yes-or-No questions could be completely replaced by a machine.

Page 18: MELJUN CORTES Automata Theory (Automata20)

Proving theorems

• We know some true statements are not provable

• But let’s forget about those.

• Can you get a computer to find the proof reasonably quickly?– Better than “try all possible proofs?”

52 years later, we still don’t know!

Page 19: MELJUN CORTES Automata Theory (Automata20)

Optimization versus proofs

• If we can find proofs quickly, then we can also optimize quickly!

• Question: Can we color Gwith so there are noconflicts?

• Proof: We can, set

v1 v2

v3 v4

v1 v2 v3 v4

(v1,R), (v2,Y), (v3,R), (v4,Y)

Page 20: MELJUN CORTES Automata Theory (Automata20)

The Cook-Levin Theorem

• However,

Constraint satisfaction is no harder thanfinding proofs quickly

It is no easier, either

Stephen CookLeonid Levin

Cook 1971, Levin 1973

Page 21: MELJUN CORTES Automata Theory (Automata20)

Equivalence of optimization problems

constraintsatisfaction

scheduling packing

coveringrouting

are all as hard as one another!

theorem-proving

Richard Karp

Q: So are they all easy or all hard?

A: We don’t know, but we suspect all hard

(1972)