MELJUN CORTES Automata Theory (Automata15)

36
(MSCS) Theory of Automata & Formal Languages Turing Machines Fall 2008 MELJUN P. CORTES, MBA,MPA,BSCS,ACS MELJUN P. CORTES, MBA,MPA,BSCS,ACS MELJUN CORTES MELJUN CORTES

description

MELJUN CORTES Automata Theory (Automata15)

Transcript of MELJUN CORTES Automata Theory (Automata15)

Page 1: MELJUN CORTES Automata Theory (Automata15)

(MSCS) Theory of Automata & Formal Languages

Turing Machines

Fall 2008

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

MELJUN CORTESMELJUN CORTES

Page 2: MELJUN CORTES Automata Theory (Automata15)

What is a computer?What is a computer?

A computer is a machine that manipulates data according to a list of instructions.

computerinput data

instructions(program)

output data

Page 3: MELJUN CORTES Automata Theory (Automata15)

Are DFAs and PDAs Are DFAs and PDAs computers?computers?

0, / a

#, / , Z0 /

1, a / 0

1

0, 1

A computer is a machine that manipulates data according to a list of instructions.

yes no!

Page 4: MELJUN CORTES Automata Theory (Automata15)

A short history of computing A short history of computing devicesdevices

Leibniz calculator (1670s)

slide rule (1600s)

abacus (Babylon 500BC, China 1300)

Babbage’s mechanical

engine(1820s)

Page 5: MELJUN CORTES Automata Theory (Automata15)

A brief history of computing A brief history of computing devicesdevices

Z3 (Germany, 1941) ENIAC (Pennsylvania, 1945)

PC (1980) MacBook Air (2008)

Page 6: MELJUN CORTES Automata Theory (Automata15)

Which of these are “real” Which of these are “real” computers?computers?

not programmable

programmable

Page 7: MELJUN CORTES Automata Theory (Automata15)

Computation is universalComputation is universal

In principle, all these computers have the same problem-solving ability

C++ java python LISP

Page 8: MELJUN CORTES Automata Theory (Automata15)

The Turing MachineThe Turing Machine

C++ java python LISP

Turing Machine

Page 9: MELJUN CORTES Automata Theory (Automata15)

The Turing MachineThe Turing Machine

The Turing Machine is an The Turing Machine is an abstract automatonabstract automaton that is that ismeant to model meant to model any physically realizable computerany physically realizable computer Using any technology (mechanical, electrical, nano, bio)Using any technology (mechanical, electrical, nano, bio) Under any physical laws (gravity, quantum, E&M)Under any physical laws (gravity, quantum, E&M) At any scale (human, quantum, cosmological)At any scale (human, quantum, cosmological)

How come there is How come there is one model one model that can capture allthat can capture allthese vastly different settings?these vastly different settings?

Why do we need an abstract model of a computer?Why do we need an abstract model of a computer?

Page 10: MELJUN CORTES Automata Theory (Automata15)

Computation and mathematical Computation and mathematical proofsproofs

Prove that...Prove that...√2 is irrational.

The equation xn + yn = zn, n ≥ 2has no integer solutions.

G = (L, R) has a perfect matching iff |(S)| ≥ |S| for every L ⊆ S.

L ⊆ {1}* is regular iff L = L0 ∪ Lq1,r ∪ ... ∪ Lqk,r

The language 0n1n is not regular.

Math is hard, let’s go shopping!

(Archimedes’ Theorem)

(Fermat-Wiles Theorem)

(Hall’s Theorem)

Page 11: MELJUN CORTES Automata Theory (Automata15)

Hilbert’s list of 23 problemsHilbert’s list of 23 problems

Leading mathematician in the 1900sLeading mathematician in the 1900s

At the 1900 International CongressAt the 1900 International Congressof Mathematicians, proposed a list ofof Mathematicians, proposed a list of23 problems for the 2023 problems for the 20thth century century

Hilbert’s 10Hilbert’s 10thth problem: problem:

David Hilbert(1862-1943)

Find a method for telling if an equation like xyz – 3xy + 6xz + 2 = 0 has integer solutions

Page 12: MELJUN CORTES Automata Theory (Automata15)

Automated theorem-provingAutomated theorem-proving

computerinput data

instructions

output

√2 is irration

al.

The equation xn + yn = zn, n ≥ 2has no integer solutions.

G = (L, R) has a perfect matching

iff |(S)| ≥ |S| for every L ⊆ S.The language 0 n1 n

is not regular.

check ifthey are

true!

xyz – 3xy + 6xz +

2 = 0 has integer solutions.

true / false

Page 13: MELJUN CORTES Automata Theory (Automata15)

Automated theorem provingAutomated theorem proving

How could automated theorem proving work?How could automated theorem proving work?

Let’s look at a typical proof:Let’s look at a typical proof:

√2 is irrational.

Assume not.Then √2 = m/n.Then m2 = 2n2

But m2 has an even number of prime factors and 2n2 has an odd number of prime factors.Contradiction.

Theorem:

Proof:

Page 14: MELJUN CORTES Automata Theory (Automata15)

First idea of automated theorem First idea of automated theorem provingproving

Checking that a proof is correct is much easier than Checking that a proof is correct is much easier than coming up with the proofcoming up with the proof

Proof:

... if we write out the proof in sufficient detail

√2 = m/n both sides ×n(√2)n = m square

(√2)2n2 = m2def of sqrt

2n2 = m2

Page 15: MELJUN CORTES Automata Theory (Automata15)

First idea of automated theorem First idea of automated theorem provingproving

Checking that a proof is correct is much Checking that a proof is correct is much easier than easier than coming up with the proofcoming up with the proof

In principle this is uncontroversialIn principle this is uncontroversial In practice, it is hard to do because writing In practice, it is hard to do because writing

proofs inproofs indetail sometimes requires a lot of workdetail sometimes requires a lot of work

A proof, if written out in sufficient detail, canbe checked mechanically

Page 16: MELJUN CORTES Automata Theory (Automata15)

Second idea of automated Second idea of automated theorem provingtheorem proving

To find if statement is true, why don’t we try To find if statement is true, why don’t we try allallpossible proofspossible proofs

After all, a proof is just After all, a proof is just a sequence of symbols a sequence of symbols (over (over alphabet alphabet {0, 1, 2, {0, 1, 2, mm, , nn, , √, √, 22, etc.}, etc.}))

If statement is true, it has a proof of If statement is true, it has a proof of finite length, say finite length, say kk

To find it, let’s just try To find it, let’s just try all possible all possible proofsproofs of length of length 11, , 22, up to , up to kk

√2 = m/n(√2)n = m

(√2)2n2 = m2

2n2 = m2

...

Page 17: MELJUN CORTES Automata Theory (Automata15)

Königsberg, 1930Königsberg, 1930

David Hilbert(1862-1943)

Kurt Gödel(1906-1978)

September 8: Hilbert gives a famous lecture“Logic and the understanding of nature”

Page 18: MELJUN CORTES Automata Theory (Automata15)

Königsberg, 1930Königsberg, 1930

David Hilbert(1862-1943)

Kurt Gödel(1906-1978)

John von Neumann(1903-1957)

I reached the conclusion that in any reasonable formal system in which provability in it can be expressed as a property of certain sentences, there must be propositions which are undecidable in it.

It is all over!

Page 19: MELJUN CORTES Automata Theory (Automata15)

What did Gödel say?What did Gödel say?

To find if statement is true, why don’t we try To find if statement is true, why don’t we try allallpossible proofspossible proofs

After all, a proof is just After all, a proof is just a sequence of symbols a sequence of symbols (over (over alphabet alphabet {0, 1, 2, {0, 1, 2, mm, , nn, , √, √, 22, etc.}, etc.}))

If statement is true, it has a proof of If statement is true, it has a proof of finite length, say finite length, say kk

To find it, let’s just try To find it, let’s just try all possible all possible proofsproofs of length of length 11, , 22, up to , up to kk

NO!

Page 20: MELJUN CORTES Automata Theory (Automata15)

Gödel’s incompleteness Gödel’s incompleteness theoremtheorem

Some mathematical statementsare true but not provable.

What are they?

Page 21: MELJUN CORTES Automata Theory (Automata15)

Example of incompletenessExample of incompleteness

Recall Hilbert’s 10Recall Hilbert’s 10thth problem: problem:

Matyashievich showed in 1970 that there Matyashievich showed in 1970 that there exists aexists apolynomial polynomial pp such that such that

Find a method for telling if an equation like xyz – 3xy + 6xz + 2 = 0 has integer solutions

p(x1, ..., xk) = 0 has no integer solutions, butthis cannot be proved

Page 22: MELJUN CORTES Automata Theory (Automata15)

Another example of Another example of incompletenessincompleteness

Recall Recall ambiguousambiguous context free grammars context free grammars

We did exercises of the typeWe did exercises of the type

“Show that “Show that GG is ambiguous” is ambiguous”

However there exists a CFG However there exists a CFG GG such that such thatG is unambiguous, but this cannot be proved

Page 23: MELJUN CORTES Automata Theory (Automata15)

Gödel’s incompleteness Gödel’s incompleteness theoremtheorem

Some mathematical statementsare true but not provable.

What does this have to do with computer science?

Page 24: MELJUN CORTES Automata Theory (Automata15)

The father of modern computer The father of modern computer sciencescienceInvented the Invented the Turing TestTuring Test to tell to tellhumans and computers aparthumans and computers apart

Broke German encryption codesBroke German encryption codesduring World War IIduring World War II

The The Turing AwardTuring Award is the “Nobel is the “Nobelprize of Computer Science”prize of Computer Science”Alan Turing

(1912-1954)

“On Computable Numbers, with an Application to the Entscheidungsproblem”

1936:

Page 25: MELJUN CORTES Automata Theory (Automata15)

Turing’s angle on Turing’s angle on incompletenessincompleteness

computer

input data

instructionsoutput

check if true!

true / false

mathematical statement

Gödel’s theorem says that a computer cannot determine the truth of mathematical statements

But there are many other things!

Page 26: MELJUN CORTES Automata Theory (Automata15)

Computer program analysisComputer program analysispublic static void main(String args[]) { System.out.println("Hello World!"); }

What does this program do?

How about this one?

public static void main(String args[]) { int i = 0; for (j = 1; j < 10; j++) { i += j; if (i == 28) { System.out.println("Hello World!"); } } }

Page 27: MELJUN CORTES Automata Theory (Automata15)

Computers cannot analyze Computers cannot analyze programs!programs!

computer

input data

instructionsoutput

does it printHello, world!

java program

The essence of Gödel’s theorem is thatcomputers cannot analyze computer programs

Page 28: MELJUN CORTES Automata Theory (Automata15)

How do you argue things like How do you argue things like that?that?

To argue what computers cannot do,we need to have a precise definitionof what a computer is.

“On Computable Numbers, with an Application to the Entscheidungsproblem”

1936:

Section 1. Computing Machines

Page 29: MELJUN CORTES Automata Theory (Automata15)

Turing MachinesTuring Machines

state control

A Turing Machine is a finite automaton with a A Turing Machine is a finite automaton with a two-way accesstwo-way access to an to an infinite tapeinfinite tape

Initially, the first few cells contain the input, and the Initially, the first few cells contain the input, and the other cells are blankother cells are blank

infinite tape

0 1 0

input

Page 30: MELJUN CORTES Automata Theory (Automata15)

Turing MachinesTuring Machines

state control

At each point in the computation, the machine seesAt each point in the computation, the machine seesits current state and the symbol at the headits current state and the symbol at the head

It can It can replace the symbol replace the symbol on the tape, on the tape, change change statestate,,and and move the headmove the head left or right left or right

0 1 a 0

head

Page 31: MELJUN CORTES Automata Theory (Automata15)

ExampleExample

…0 1 a 0q1 q2

a/bL

Replace a with b, and move head left

current state

…0 1 b 0q1 q2

a/bL

current state

Page 32: MELJUN CORTES Automata Theory (Automata15)

Formal DefinitionFormal Definition

A Turing Machine is A Turing Machine is (Q, (Q, ,, , , , q, q00, q, qaccacc, q, qrejrej)):: QQ is a finite set of is a finite set of statesstates;; is the is the input alphabetinput alphabet;; is the is the tape alphabettape alphabet ( ( ) including the ) including the blank symbol blank symbol ☐☐ qq00 in in QQ is the is the initial stateinitial state;;

qqaccacc, q, qrejrej inin Q Q are the are the acceptingaccepting and and rejecting staterejecting state;; is the transition functionis the transition function

: (Q – {qacc, qrej}) → Q {L, R}

Turing Machines are deterministic

Page 33: MELJUN CORTES Automata Theory (Automata15)

Language of a Turing MachineLanguage of a Turing Machine

The The language recognized by a TM language recognized by a TM is the set of all is the set of all inputs that make it reach inputs that make it reach qqaccacc

Something strange can happen in a Turing Machine:Something strange can happen in a Turing Machine:

q0

qacc

qrej

= {0, 1}

input: ☐/☐R

0/0R

1/1RThis machinenever halts

Page 34: MELJUN CORTES Automata Theory (Automata15)

Looping behaviorLooping behavior

Inputs can be divided into three types:Inputs can be divided into three types: 1. Reach the state 1. Reach the state qqaccacc and halt and halt

2. Reach the state 2. Reach the state qqrejrej and halt and halt 3. Loop forever3. Loop forever

The language recognized by a TM = type The language recognized by a TM = type 1 inputs1 inputs

Page 35: MELJUN CORTES Automata Theory (Automata15)

The Church-Turing ThesisThe Church-Turing Thesis

Turing Machinequantum computing

DNA computing

cosmic computing

Page 36: MELJUN CORTES Automata Theory (Automata15)

The Church-Turing ThesisThe Church-Turing Thesis

“On Computable Numbers, with an Application to the Entscheidungsproblem”

1936:

Section 9. The extent of the computable numbers

All arguments [for the CT Thesis] which can be given are bound to be, fundamentally, appeals to intuition, and for this reason rather unsatisfactory mathematically. The arguments which I shall use are of three kinds: 1. A direct appeal to intuition 2. A proof of the equivalence of two definitions (In case the new definition has greater intuitive appeal) 3. Giving examples of large classes of numbers which are computable.