INF2080 Church Turing Thesis and Decidability Daniel Lupp - - PowerPoint PPT Presentation

inf2080
SMART_READER_LITE
LIVE PREVIEW

INF2080 Church Turing Thesis and Decidability Daniel Lupp - - PowerPoint PPT Presentation

INF2080 Church Turing Thesis and Decidability Daniel Lupp Universitetet i Oslo 1st March 2018 Department of University of Informatics Oslo INF2080 Lecture :: 1st March 1 / 43 Short Recap We have looked at Turing machines as a


slide-1
SLIDE 1

INF2080

Church Turing Thesis and Decidability Daniel Lupp

Universitetet i Oslo

1st March 2018

Department of Informatics University of Oslo

INF2080 Lecture :: 1st March 1 / 43

slide-2
SLIDE 2

Short Recap

We have looked at Turing machines as a computational model

INF2080 Lecture :: 1st March 2 / 43

slide-3
SLIDE 3

Short Recap

We have looked at Turing machines as a computational model a finite state machine with an infinite tape, upon which a head can move, read, and write

INF2080 Lecture :: 1st March 2 / 43

slide-4
SLIDE 4

Short Recap

We have looked at Turing machines as a computational model a finite state machine with an infinite tape, upon which a head can move, read, and write have looked at Turing machine variants, seen that they are equivalent:

INF2080 Lecture :: 1st March 2 / 43

slide-5
SLIDE 5

Short Recap

We have looked at Turing machines as a computational model a finite state machine with an infinite tape, upon which a head can move, read, and write have looked at Turing machine variants, seen that they are equivalent: the LRS Turing machine (the head can move left, right, or stay put) the multitape Turing machine (multiple tapes, multiple heads) the nondeterministic Turing machine the enumerator

INF2080 Lecture :: 1st March 2 / 43

slide-6
SLIDE 6

Church Turing Thesis

So, all variants of Turing machines we’ve seen are equivalent in expressivity.

INF2080 Lecture :: 1st March 3 / 43

slide-7
SLIDE 7

Church Turing Thesis

So, all variants of Turing machines we’ve seen are equivalent in expressivity. This is no coincidence: all can perform finite work in a single step, all have unlimited access to infinite memory.

INF2080 Lecture :: 1st March 3 / 43

slide-8
SLIDE 8

Church Turing Thesis

So, all variants of Turing machines we’ve seen are equivalent in expressivity. This is no coincidence: all can perform finite work in a single step, all have unlimited access to infinite memory. In fact, Turing machines capture all such computational models

INF2080 Lecture :: 1st March 3 / 43

slide-9
SLIDE 9

Church-Turing Thesis

the notion of algorithm is not new

INF2080 Lecture :: 1st March 4 / 43

slide-10
SLIDE 10

Church-Turing Thesis

the notion of algorithm is not new yet a formal description of what an algorithm is, or what is solvable using algorithms, did not appear until the 20th century.

INF2080 Lecture :: 1st March 4 / 43

slide-11
SLIDE 11

Church-Turing Thesis

the notion of algorithm is not new yet a formal description of what an algorithm is, or what is solvable using algorithms, did not appear until the 20th century. Many mathematicians assumed that one needed only to find the right “method”, did not even consider something might be unsolvable.

INF2080 Lecture :: 1st March 4 / 43

slide-12
SLIDE 12

Church-Turing Thesis

Church and Turing independently formalized the notion of algorithm

INF2080 Lecture :: 1st March 5 / 43

slide-13
SLIDE 13

Church-Turing Thesis

Church and Turing independently formalized the notion of algorithm Previous, intuitive notion: a method according to which after a finite number of

  • perations an answer is given (paraphrased, many formulations)

INF2080 Lecture :: 1st March 5 / 43

slide-14
SLIDE 14

Church-Turing Thesis

Church and Turing independently formalized the notion of algorithm Previous, intuitive notion: a method according to which after a finite number of

  • perations an answer is given (paraphrased, many formulations)

Formal: an algorithm is a decidable Turing machine (deciders)

INF2080 Lecture :: 1st March 5 / 43

slide-15
SLIDE 15

Church-Turing Thesis

Church and Turing independently formalized the notion of algorithm Previous, intuitive notion: a method according to which after a finite number of

  • perations an answer is given (paraphrased, many formulations)

Formal: an algorithm is a decidable Turing machine (deciders) Church Turing thesis: each intuitive definition of algorithms can be described by decidable Turing machines

INF2080 Lecture :: 1st March 5 / 43

slide-16
SLIDE 16

Decidability

Definition A language L is decidable if a Turing machine ML exists that decides it, that is, if ML either accepts or rejects any input w.

INF2080 Lecture :: 1st March 6 / 43

slide-17
SLIDE 17

Decidability

Definition A language L is decidable if a Turing machine ML exists that decides it, that is, if ML either accepts or rejects any input w. This week we will discuss the decidability of various problems related to the classes of languages we have seen so far: regular, context-free, and Turing-recognizable.

INF2080 Lecture :: 1st March 6 / 43

slide-18
SLIDE 18

Decidability

Definition A language L is decidable if a Turing machine ML exists that decides it, that is, if ML either accepts or rejects any input w. This week we will discuss the decidability of various problems related to the classes of languages we have seen so far: regular, context-free, and Turing-recognizable. Acceptance problem: Given a DFA/NFA/CFG/PDA/TM/... and an input w, does the machine/grammar accept w?

INF2080 Lecture :: 1st March 6 / 43

slide-19
SLIDE 19

Decidability

Definition A language L is decidable if a Turing machine ML exists that decides it, that is, if ML either accepts or rejects any input w. This week we will discuss the decidability of various problems related to the classes of languages we have seen so far: regular, context-free, and Turing-recognizable. Acceptance problem: Given a DFA/NFA/CFG/PDA/TM/... and an input w, does the machine/grammar accept w? Emptiness problem: Given a DFA/NFA/CFG/PDA/TM/..., is its generated language empty?

INF2080 Lecture :: 1st March 6 / 43

slide-20
SLIDE 20

Decidability

Definition A language L is decidable if a Turing machine ML exists that decides it, that is, if ML either accepts or rejects any input w. This week we will discuss the decidability of various problems related to the classes of languages we have seen so far: regular, context-free, and Turing-recognizable. Acceptance problem: Given a DFA/NFA/CFG/PDA/TM/... and an input w, does the machine/grammar accept w? Emptiness problem: Given a DFA/NFA/CFG/PDA/TM/..., is its generated language empty? Equality problem: Given two DFA/NFA/CFG/PDA/TM/..., are the two generated languages equal?

INF2080 Lecture :: 1st March 6 / 43

slide-21
SLIDE 21

Notation

For an object O (graph, automaton, Turing machine, etc.), let O represent its string

  • representation. For example:

1 2 3 can be represented as the string {1, 2, 3, (1, 2), (1, 3)}

INF2080 Lecture :: 1st March 7 / 43

slide-22
SLIDE 22

Acceptance problem - DFA

Let ADFA = {B, w | B is a DFA that accepts input string w}

INF2080 Lecture :: 1st March 8 / 43

slide-23
SLIDE 23

Acceptance problem - DFA

Let ADFA = {B, w | B is a DFA that accepts input string w} Acceptance problem “Given B and w, does B accept w?” ⇔ “B, w ∈ ADFA”?

INF2080 Lecture :: 1st March 8 / 43

slide-24
SLIDE 24

Acceptance problem - DFA

Let ADFA = {B, w | B is a DFA that accepts input string w} Acceptance problem “Given B and w, does B accept w?” ⇔ “B, w ∈ ADFA”? Theorem ADFA is a decidable language. Proof idea: We create a Turing machine that simulates B on w:

INF2080 Lecture :: 1st March 8 / 43

slide-25
SLIDE 25

Acceptance problem - DFA

Let ADFA = {B, w | B is a DFA that accepts input string w} Acceptance problem “Given B and w, does B accept w?” ⇔ “B, w ∈ ADFA”? Theorem ADFA is a decidable language. Proof idea: We create a Turing machine that simulates B on w: MDFA = On input B, w 1. Simulate B on w. 2. If the simulation ends in an accept state, accept, if it ends in a nonaccepting state, reject.

INF2080 Lecture :: 1st March 8 / 43

slide-26
SLIDE 26

Acceptance problem - DFA

Corollary The class of regular languages is decidable. Proof: For a given regular language L, we need to construct a decider ML that accepts all w ∈ L and rejects all s ∈ L.

INF2080 Lecture :: 1st March 9 / 43

slide-27
SLIDE 27

Acceptance problem - DFA

Corollary The class of regular languages is decidable. Proof: For a given regular language L, we need to construct a decider ML that accepts all w ∈ L and rejects all s ∈ L. we can encode its DFA B into a decider for L: ML = On input w 1. Simulate MDFA on B, w. 2. If MDFA accepts, accept, if it rejects, reject.

INF2080 Lecture :: 1st March 9 / 43

slide-28
SLIDE 28

Acceptance problem - NFA/RE

What about NFAs and REs?

INF2080 Lecture :: 1st March 10 / 43

slide-29
SLIDE 29

Acceptance problem - NFA/RE

What about NFAs and REs? We have seen that they have equivalent expressive power to DFAs

INF2080 Lecture :: 1st March 10 / 43

slide-30
SLIDE 30

Acceptance problem - NFA/RE

What about NFAs and REs? We have seen that they have equivalent expressive power to DFAs So are the languages ANFA and ARE decidable?

INF2080 Lecture :: 1st March 10 / 43

slide-31
SLIDE 31

Acceptance problem - NFA/RE

What about NFAs and REs? We have seen that they have equivalent expressive power to DFAs So are the languages ANFA and ARE decidable? We can use the known procedures to convert NFA→DFA and RE→NFA!

INF2080 Lecture :: 1st March 10 / 43

slide-32
SLIDE 32

Acceptance problem - NFA/RE

What about NFAs and REs? We have seen that they have equivalent expressive power to DFAs So are the languages ANFA and ARE decidable? We can use the known procedures to convert NFA→DFA and RE→NFA! ANFA = {B, w | B is an NFA that accepts w} Theorem The language ANFA is decidable.

INF2080 Lecture :: 1st March 10 / 43

slide-33
SLIDE 33

Acceptance problem - NFA/RE

What about NFAs and REs? We have seen that they have equivalent expressive power to DFAs So are the languages ANFA and ARE decidable? We can use the known procedures to convert NFA→DFA and RE→NFA! ANFA = {B, w | B is an NFA that accepts w} Theorem The language ANFA is decidable. Proof: MNFA = On input B, w 1. Convert B to an equivalent DFA C. 2. Simulate MDFA on input B, w if it accepts, accept; if it rejects, reject.

INF2080 Lecture :: 1st March 10 / 43

slide-34
SLIDE 34

Acceptance problem - NFA/RE

ARE = {R, w | B is a regular expression that generates w} Theorem The language ARE is decidable.

INF2080 Lecture :: 1st March 11 / 43

slide-35
SLIDE 35

Acceptance problem - NFA/RE

ARE = {R, w | B is a regular expression that generates w} Theorem The language ARE is decidable. Proof: Similar to before, however now we reduce to NFA case: MRE = On input R, w 1. Convert R to an equivalent NFA B. 2. Simulate MNFA on input B, w if it accepts, accept; if it rejects, reject.

INF2080 Lecture :: 1st March 11 / 43

slide-36
SLIDE 36

Acceptance problem - Regular languages

So we see that it is does not matter which computational model we use to represent the regular language; this has no effect on decidabillity

INF2080 Lecture :: 1st March 12 / 43

slide-37
SLIDE 37

Acceptance problem - Regular languages

So we see that it is does not matter which computational model we use to represent the regular language; this has no effect on decidabillity Recall the Church-Turing thesis: intuitive notion of algorithm/procedure ⇔ Turing machine algorithm

INF2080 Lecture :: 1st March 12 / 43

slide-38
SLIDE 38

Acceptance problem - Regular languages

So we see that it is does not matter which computational model we use to represent the regular language; this has no effect on decidabillity Recall the Church-Turing thesis: intuitive notion of algorithm/procedure ⇔ Turing machine algorithm Our “procedures” of converting NFA→DFA, RE→NFA, CFG↔PDA can be formally described using a decidable TM!

INF2080 Lecture :: 1st March 12 / 43

slide-39
SLIDE 39

Emptiness problem - Regular languages

Next “decision problem:” Given a DFA A, is the language generated by A empty?

INF2080 Lecture :: 1st March 13 / 43

slide-40
SLIDE 40

Emptiness problem - Regular languages

Next “decision problem:” Given a DFA A, is the language generated by A empty? ⇔ A ∈ EDFA = {A | A is a DFA and L(A) = ∅}?

INF2080 Lecture :: 1st March 13 / 43

slide-41
SLIDE 41

Emptiness problem - Regular languages

Next “decision problem:” Given a DFA A, is the language generated by A empty? ⇔ A ∈ EDFA = {A | A is a DFA and L(A) = ∅}? When does a DFA accept a string w?

INF2080 Lecture :: 1st March 13 / 43

slide-42
SLIDE 42

Emptiness problem - Regular languages

Next “decision problem:” Given a DFA A, is the language generated by A empty? ⇔ A ∈ EDFA = {A | A is a DFA and L(A) = ∅}? When does a DFA accept a string w? When it reaches an accept state!

INF2080 Lecture :: 1st March 13 / 43

slide-43
SLIDE 43

Emptiness problem - Regular languages

Next “decision problem:” Given a DFA A, is the language generated by A empty? ⇔ A ∈ EDFA = {A | A is a DFA and L(A) = ∅}? When does a DFA accept a string w? When it reaches an accept state! So all the TM has to do is check whether an accept state is reachable from the start state.

INF2080 Lecture :: 1st March 13 / 43

slide-44
SLIDE 44

Emptiness problem - Regular languages

Next “decision problem:” Given a DFA A, is the language generated by A empty? ⇔ A ∈ EDFA = {A | A is a DFA and L(A) = ∅}? When does a DFA accept a string w? When it reaches an accept state! So all the TM has to do is check whether an accept state is reachable from the start state. We use the “marking” technique we have previously seen to keep track of the DFA’s states that have been reached.

INF2080 Lecture :: 1st March 13 / 43

slide-45
SLIDE 45

Emptiness problem - Regular languages

Theorem The language EDFA is decidable. Proof: NDFA = On input A 1. Mark the start state of A. 2. Repeat 3. until no new states are marked: 3. Mark any state with an incoming transition from a marked state. 4. If no accept state is reached,accept; else, reject.

INF2080 Lecture :: 1st March 14 / 43

slide-46
SLIDE 46

Equality problem - Regular languages

What if we have two regular languages, accepted by DFAs A and B, and want to check whether they are equal?

INF2080 Lecture :: 1st March 15 / 43

slide-47
SLIDE 47

Equality problem - Regular languages

What if we have two regular languages, accepted by DFAs A and B, and want to check whether they are equal? ⇔ A, B ∈ EQDFA = {A, B | A and B are DFAs and L(A) = L(B)}?

INF2080 Lecture :: 1st March 15 / 43

slide-48
SLIDE 48

Equality problem - Regular languages

What if we have two regular languages, accepted by DFAs A and B, and want to check whether they are equal? ⇔ A, B ∈ EQDFA = {A, B | A and B are DFAs and L(A) = L(B)}? Now we use the set theoretic notion of symmetric difference to help us!

INF2080 Lecture :: 1st March 15 / 43

slide-49
SLIDE 49

Equality problem - Regular languages

What if we have two regular languages, accepted by DFAs A and B, and want to check whether they are equal? ⇔ A, B ∈ EQDFA = {A, B | A and B are DFAs and L(A) = L(B)}? Now we use the set theoretic notion of symmetric difference to help us! The symmetric difference of two languages L(A) and L(B) is defined as (L(A) ∩ L(B)) ∪ (L(A) ∩ L(B))

INF2080 Lecture :: 1st March 15 / 43

slide-50
SLIDE 50

Equality problem - Regular languages

What if we have two regular languages, accepted by DFAs A and B, and want to check whether they are equal? ⇔ A, B ∈ EQDFA = {A, B | A and B are DFAs and L(A) = L(B)}? Now we use the set theoretic notion of symmetric difference to help us! The symmetric difference of two languages L(A) and L(B) is defined as (L(A) ∩ L(B)) ∪ (L(A) ∩ L(B))

L(B) L(A)

INF2080 Lecture :: 1st March 15 / 43

slide-51
SLIDE 51

Equality problem - Regular languages

What if we have two regular languages, accepted by DFAs A and B, and want to check whether they are equal? ⇔ A, B ∈ EQDFA = {A, B | A and B are DFAs and L(A) = L(B)}? Now we use the set theoretic notion of symmetric difference to help us! The symmetric difference of two languages L(A) and L(B) is defined as (L(A) ∩ L(B)) ∪ (L(A) ∩ L(B))

L(B) L(A) L(B) L(A)

INF2080 Lecture :: 1st March 15 / 43

slide-52
SLIDE 52

Equality problem - Regular languages

What if we have two regular languages, accepted by DFAs A and B, and want to check whether they are equal? ⇔ A, B ∈ EQDFA = {A, B | A and B are DFAs and L(A) = L(B)}? Now we use the set theoretic notion of symmetric difference to help us! The symmetric difference of two languages L(A) and L(B) is defined as (L(A) ∩ L(B)) ∪ (L(A) ∩ L(B))

L(B) L(A) L(B) L(A)

Two sets are equal if and only if their symmetric difference is empty!

INF2080 Lecture :: 1st March 15 / 43

slide-53
SLIDE 53

Equality problem - Regular languages

What if we have two regular languages, accepted by DFAs A and B, and want to check whether they are equal? ⇔ A, B ∈ EQDFA = {A, B | A and B are DFAs and L(A) = L(B)}? Now we use the set theoretic notion of symmetric difference to help us! The symmetric difference of two languages L(A) and L(B) is defined as (L(A) ∩ L(B)) ∪ (L(A) ∩ L(B))

L(B) L(A) L(B) L(A)

Two sets are equal if and only if their symmetric difference is empty!→ emptiness problem!

INF2080 Lecture :: 1st March 15 / 43

slide-54
SLIDE 54

Equality problem - Regular languages

(L(A) ∩ L(B)) ∪ (L(A) ∩ L(B)) Recall closure properties of regular languages: closed under union, intersection, and complement (among other things)

INF2080 Lecture :: 1st March 16 / 43

slide-55
SLIDE 55

Equality problem - Regular languages

(L(A) ∩ L(B)) ∪ (L(A) ∩ L(B)) Recall closure properties of regular languages: closed under union, intersection, and complement (among other things) have seen procedures for constructing the DFA for unions/intersections/complements of regular languages.

INF2080 Lecture :: 1st March 16 / 43

slide-56
SLIDE 56

Equality problem - Regular languages

(L(A) ∩ L(B)) ∪ (L(A) ∩ L(B)) Recall closure properties of regular languages: closed under union, intersection, and complement (among other things) have seen procedures for constructing the DFA for unions/intersections/complements of regular languages. Using these, we can construct a DFA that accepts the symmetric difference of two regular languages.

INF2080 Lecture :: 1st March 16 / 43

slide-57
SLIDE 57

Equality problem - Regular languages

Theorem The language EQDFA is decidable.

INF2080 Lecture :: 1st March 17 / 43

slide-58
SLIDE 58

Equality problem - Regular languages

Theorem The language EQDFA is decidable. Proof: SDFA = On input A, B 1. Construct C, the DFA of the symmetric difference of L(A) and L(B). 2. Run NDFA on C. (checks whether L(C) is empty) 3. If NDFA accepts, accept; if NDFA rejects, reject.

INF2080 Lecture :: 1st March 17 / 43

slide-59
SLIDE 59

Summary - Regular languages

Regular languages are decidable:

INF2080 Lecture :: 1st March 18 / 43

slide-60
SLIDE 60

Summary - Regular languages

Regular languages are decidable: the acceptance problem (does A accept w?) is decidable, independent of the computational model in which we chose to describe regular languages;

INF2080 Lecture :: 1st March 18 / 43

slide-61
SLIDE 61

Summary - Regular languages

Regular languages are decidable: the acceptance problem (does A accept w?) is decidable, independent of the computational model in which we chose to describe regular languages; the emptiness problem (is L(A) empty?) is decidable;

INF2080 Lecture :: 1st March 18 / 43

slide-62
SLIDE 62

Summary - Regular languages

Regular languages are decidable: the acceptance problem (does A accept w?) is decidable, independent of the computational model in which we chose to describe regular languages; the emptiness problem (is L(A) empty?) is decidable; the equality problem (are L(A) and L(B) equal?) is decidable.

INF2080 Lecture :: 1st March 18 / 43

slide-63
SLIDE 63

Summary - Regular languages

Regular languages are decidable: the acceptance problem (does A accept w?) is decidable, independent of the computational model in which we chose to describe regular languages; the emptiness problem (is L(A) empty?) is decidable; the equality problem (are L(A) and L(B) equal?) is decidable. in each case: we reduced the question to checking membership in a language.

INF2080 Lecture :: 1st March 18 / 43

slide-64
SLIDE 64

Decision problems - CFLs

What about the decision problems for context-free languages?

INF2080 Lecture :: 1st March 19 / 43

slide-65
SLIDE 65

Decision problems - CFLs

What about the decision problems for context-free languages? Are the languages ACFG ={G, w | G is a CFG that generates w} ECFG ={G | G is a CFG and L(G) = ∅} EQCFG ={G, H | G and H are CFGs and L(G) = L(H)} decidable?

INF2080 Lecture :: 1st March 19 / 43

slide-66
SLIDE 66

Acceptance problem - CFLs

Theorem The language ACFG is decidable. Proof:

INF2080 Lecture :: 1st March 20 / 43

slide-67
SLIDE 67

Acceptance problem - CFLs

Theorem The language ACFG is decidable. Proof: We cannot do the proof analogously to the DFA case: PDAs do not necessarily always terminate (they can endlessly loop, writing on to the stack).

INF2080 Lecture :: 1st March 20 / 43

slide-68
SLIDE 68

Acceptance problem - CFLs

Theorem The language ACFG is decidable. Proof: We cannot do the proof analogously to the DFA case: PDAs do not necessarily always terminate (they can endlessly loop, writing on to the stack). Instead, we use the fact that every CFG can be converted to a grammar in Chomsky Normal Form.

INF2080 Lecture :: 1st March 20 / 43

slide-69
SLIDE 69

Acceptance problem - CFLs

Theorem The language ACFG is decidable. Proof: We cannot do the proof analogously to the DFA case: PDAs do not necessarily always terminate (they can endlessly loop, writing on to the stack). Instead, we use the fact that every CFG can be converted to a grammar in Chomsky Normal Form. One can show (Problem 2.38 in Sipser) that if a grammar is CNF, then every derivation of w has length 2n − 1, where n is the length of w.

INF2080 Lecture :: 1st March 20 / 43

slide-70
SLIDE 70

Acceptance problem - CFLs

Theorem The language ACFG is decidable. Proof: We cannot do the proof analogously to the DFA case: PDAs do not necessarily always terminate (they can endlessly loop, writing on to the stack). Instead, we use the fact that every CFG can be converted to a grammar in Chomsky Normal Form. One can show (Problem 2.38 in Sipser) that if a grammar is CNF, then every derivation of w has length 2n − 1, where n is the length of w. That way we only need to check all derivations of length 2n − 1 to see if any generates w!

INF2080 Lecture :: 1st March 20 / 43

slide-71
SLIDE 71

Acceptance problem - CFLs

Theorem The language ACFG is decidable. Proof: MCFG = On input G, w 1. Convert G to a CFG in Chomsky Normal Form. 2. If n = 0, where n is the length of w, list all derivations with 1 step. Else, list all derivations with 2n − 1 steps. 3. If any of the derivations generate w accept; otherwise, reject.

INF2080 Lecture :: 1st March 21 / 43

slide-72
SLIDE 72

Decidability of CFLs

As in the regular language case, we can use this last result to show: Corollary Every context-free language is decidable.

INF2080 Lecture :: 1st March 22 / 43

slide-73
SLIDE 73

Decidability of CFLs

As in the regular language case, we can use this last result to show: Corollary Every context-free language is decidable. Proof: completely analogous to the DFA/regular case: ML = On input w 1. Simulate MCFG on B, w. 2. If MCFG accepts, accept, if it rejects, reject.

INF2080 Lecture :: 1st March 22 / 43

slide-74
SLIDE 74

Emptiness problem - CFLs

Theorem The language ECFG = {G | G is a CFG and L(G) = ∅} is decidable. Proof idea: In the DFA case, we checked reachability of accept states from the start state through a marking procedure.

INF2080 Lecture :: 1st March 23 / 43

slide-75
SLIDE 75

Emptiness problem - CFLs

Theorem The language ECFG = {G | G is a CFG and L(G) = ∅} is decidable. Proof idea: In the DFA case, we checked reachability of accept states from the start state through a marking procedure. Can we do the same here?

INF2080 Lecture :: 1st March 23 / 43

slide-76
SLIDE 76

Emptiness problem - CFLs

Theorem The language ECFG = {G | G is a CFG and L(G) = ∅} is decidable. Proof idea: In the DFA case, we checked reachability of accept states from the start state through a marking procedure. Can we do the same here? Yes! but slightly differently. Consider the grammar consisting of only S → S. If we were to start with S and iteratively generate all derivations, we would never terminate.

INF2080 Lecture :: 1st March 23 / 43

slide-77
SLIDE 77

Emptiness problem - CFLs

Theorem The language ECFG = {G | G is a CFG and L(G) = ∅} is decidable. Proof idea: In the DFA case, we checked reachability of accept states from the start state through a marking procedure. Can we do the same here? Yes! but slightly differently. Consider the grammar consisting of only S → S. If we were to start with S and iteratively generate all derivations, we would never terminate. We’re interested in finding out whether a string of terminals can be generated from S. So why not first mark terminals, then mark a variable A if there is a rule A → s where s consists of marked symbols?

INF2080 Lecture :: 1st March 23 / 43

slide-78
SLIDE 78

Emptiness problem - CFLs

Theorem The language ECFG = {G | G is a CFG and L(G) = ∅} is decidable. Proof idea: In the DFA case, we checked reachability of accept states from the start state through a marking procedure. Can we do the same here? Yes! but slightly differently. Consider the grammar consisting of only S → S. If we were to start with S and iteratively generate all derivations, we would never terminate. We’re interested in finding out whether a string of terminals can be generated from S. So why not first mark terminals, then mark a variable A if there is a rule A → s where s consists of marked symbols?→ go through derivations “backwards”. If S is marked, then a string of terminals can be generated.

INF2080 Lecture :: 1st March 23 / 43

slide-79
SLIDE 79

Emptiness problem - CFLs

Theorem The language ECFG = {G | G is a CFG and L(G) = ∅} is decidable. Example: Grammar S → ARB A → a B → b R → aRb | ε

INF2080 Lecture :: 1st March 24 / 43

slide-80
SLIDE 80

Emptiness problem - CFLs

Theorem The language ECFG = {G | G is a CFG and L(G) = ∅} is decidable. Example: Grammar S → ARB A → ˙ a B → ˙ b R → ˙ aR ˙ b | ˙ ε

INF2080 Lecture :: 1st March 25 / 43

slide-81
SLIDE 81

Emptiness problem - CFLs

Theorem The language ECFG = {G | G is a CFG and L(G) = ∅} is decidable. Example: Grammar S → ˙ A ˙ R ˙ B ˙ A → ˙ a ˙ B → ˙ b ˙ R → ˙ a ˙ R ˙ b | ˙ ε

INF2080 Lecture :: 1st March 26 / 43

slide-82
SLIDE 82

Emptiness problem - CFLs

Theorem The language ECFG = {G | G is a CFG and L(G) = ∅} is decidable. Example: Grammar ˙ S → ˙ A ˙ R ˙ B ˙ A → ˙ a ˙ B → ˙ b ˙ R → ˙ a ˙ R ˙ b | ˙ ε

INF2080 Lecture :: 1st March 27 / 43

slide-83
SLIDE 83

Emptiness problem - CFLs

Theorem The language ECFG = {G | G is a CFG and L(G) = ∅} is decidable. Example: Grammar ˙ S → ˙ A ˙ R ˙ B ˙ A → ˙ a ˙ B → ˙ b ˙ R → ˙ a ˙ R ˙ b | ˙ ε → S is marked, so language is not empty!

INF2080 Lecture :: 1st March 27 / 43

slide-84
SLIDE 84

Emptiness problem - CFLs

Theorem The language ECFG = {G | G is a CFG and L(G) = ∅} is decidable. Proof: NCFG = On input G 1. Mark all terminal symbols in G. 2. Repeat 3. until no new variables are marked: 3. Mark any variable A where G has a rule A → U1 . . . Uk and each symbol Ui has been marked. 4. If the start variable is not marked, accept. otherwise, reject.

INF2080 Lecture :: 1st March 28 / 43

slide-85
SLIDE 85

Equality problem - CFLs

So what about EQCFG = {G, H | G and H are CFGs and L(G) = L(H)}? Is it decidable? Before we used the symmetric difference (L(A) ∩ L(B)) ∪ (L(A) ∩ L(B)) to use the emptiness decider.

INF2080 Lecture :: 1st March 29 / 43

slide-86
SLIDE 86

Equality problem - CFLs

So what about EQCFG = {G, H | G and H are CFGs and L(G) = L(H)}? Is it decidable? Before we used the symmetric difference (L(A) ∩ L(B)) ∪ (L(A) ∩ L(B)) to use the emptiness decider. But context-free languages are not closed under complementation or intersection!

INF2080 Lecture :: 1st March 29 / 43

slide-87
SLIDE 87

Equality problem - CFLs

So what about EQCFG = {G, H | G and H are CFGs and L(G) = L(H)}? Is it decidable? Before we used the symmetric difference (L(A) ∩ L(B)) ∪ (L(A) ∩ L(B)) to use the emptiness decider. But context-free languages are not closed under complementation or intersection! in fact, EQCFG is not decidable. Tomorrow we’ll see techniques to show this.

INF2080 Lecture :: 1st March 29 / 43

slide-88
SLIDE 88

Summary- CFLs

the acceptance and emptiness decision problems are decidable for context-free languages hence, each context-free language is decidable. checking equivalence of two grammars (in the sense of languages generated) is not decidable!

INF2080 Lecture :: 1st March 30 / 43

slide-89
SLIDE 89

Acceptance problems - TMs

What about Turing-recognizable languages? Are they also decidable?

INF2080 Lecture :: 1st March 31 / 43

slide-90
SLIDE 90

Acceptance problems - TMs

What about Turing-recognizable languages? Are they also decidable? If they were, every Turing machine could be converted into an equivalent TM that is guaranteed to halt on every input!

INF2080 Lecture :: 1st March 31 / 43

slide-91
SLIDE 91

Acceptance problem - TMs

First things first... Theorem The language ATM = {M, w | M is a TM that accepts w} is Turing-recognizable.

INF2080 Lecture :: 1st March 32 / 43

slide-92
SLIDE 92

Acceptance problem - TMs

First things first... Theorem The language ATM = {M, w | M is a TM that accepts w} is Turing-recognizable. Proof: U = On input M, w 1. Simulate M on w. 2. If M ever enters its accept state, accept; if M ever enters its reject state, reject.

INF2080 Lecture :: 1st March 32 / 43

slide-93
SLIDE 93

Acceptance problem - TMs

First things first... Theorem The language ATM = {M, w | M is a TM that accepts w} is Turing-recognizable. Proof: U = On input M, w 1. Simulate M on w. 2. If M ever enters its accept state, accept; if M ever enters its reject state, reject. U is an example of a universal Turing machine!

INF2080 Lecture :: 1st March 32 / 43

slide-94
SLIDE 94

Acceptance problem - TMs

So what about decidability?

INF2080 Lecture :: 1st March 33 / 43

slide-95
SLIDE 95

Acceptance problem - TMs

So what about decidability? Let’s assume there exists a decider H for ATM, i.e., H(M, w) = accept if M accepts w, and H(M, w) = reject if M does not accept w.

INF2080 Lecture :: 1st March 33 / 43

slide-96
SLIDE 96

Acceptance problem - TMs

So what about decidability? Let’s assume there exists a decider H for ATM, i.e., H(M, w) = accept if M accepts w, and H(M, w) = reject if M does not accept w. We are going to use a standard mathematical trick in order to create a contradiction

INF2080 Lecture :: 1st March 33 / 43

slide-97
SLIDE 97

Diagonalization method

Let’s write all Turing machines into the following table: M1 M2 M3 . . . M1 accept accept M2 accept M3 accept accept accept . . . Each cell (i, j) represents whether Mi accepts the string Mj (the string representation of machine Mj). accept means that it accepts, blank means it loops or rejects.

INF2080 Lecture :: 1st March 34 / 43

slide-98
SLIDE 98

Diagonalization method

Let’s write all Turing machines into the following table: M1 M2 M3 . . . M1 accept accept M2 accept M3 accept accept accept . . . Each cell (i, j) represents whether Mi accepts the string Mj (the string representation of machine Mj). accept means that it accepts, blank means it loops or rejects. The decider H let’s us fill out the blank cells with reject.

INF2080 Lecture :: 1st March 34 / 43

slide-99
SLIDE 99

Diagonalization method

Result of H with input Mi, Mj: M1 M2 M3 . . . M1 accept reject accept M2 reject reject accept M3 accept accept accept . . . Each cell (i, j) represents H(Mi, Mj)

INF2080 Lecture :: 1st March 35 / 43

slide-100
SLIDE 100

Diagonalization method

Result of H with input Mi, Mj: M1 M2 M3 . . . M1 accept reject accept M2 reject reject accept M3 accept accept accept . . . Each cell (i, j) represents H(Mi, Mj) We create a new decider D that considers the diagonal

INF2080 Lecture :: 1st March 36 / 43

slide-101
SLIDE 101

Diagonalization method

Result of H with input Mi, Mj: M1 M2 M3 . . . M1 accept reject accept M2 reject reject accept M3 accept accept accept . . . Each cell (i, j) represents H(Mi, Mj) We create a new decider D that considers the diagonal takes Mi as input, checks result of H(Mi, Mi) and flips the result

INF2080 Lecture :: 1st March 36 / 43

slide-102
SLIDE 102

Diagonalization method

Result of H with input Mi, Mj: M1 M2 M3 . . . M1 reject reject accept M2 reject accept accept M3 accept accept reject . . . Each cell (i, j) represents H(Mi, Mj) We create a new decider D that considers the diagonal takes Mi as input, checks result of H(Mi, Mi) and flips the result

INF2080 Lecture :: 1st March 36 / 43

slide-103
SLIDE 103

Diagonalization method

But D must occure in the table too! M1 M2 M3 . . . D . . . M1 accept reject accept M2 reject reject accept M3 accept accept accept . . . D ? . . . What does D do with input D? if D(D) = accept, H(D, D) = reject.

INF2080 Lecture :: 1st March 37 / 43

slide-104
SLIDE 104

Diagonalization method

But D must occure in the table too! M1 M2 M3 . . . D . . . M1 accept reject accept M2 reject reject accept M3 accept accept accept . . . D ? . . . What does D do with input D? if D(D) = accept, H(D, D) = reject. This means D does not accept D(D), i.e., D(D) = reject.

INF2080 Lecture :: 1st March 37 / 43

slide-105
SLIDE 105

Diagonalization method

But D must occure in the table too! M1 M2 M3 . . . D . . . M1 reject reject accept M2 reject accept accept M3 accept accept reject . . . D ? . . . What does D do with input D? if D(D) = accept, H(D, D) = reject. This means D does not accept D(D), i.e., D(D) = reject. if D(D) = reject, H(D, D) = accept.

INF2080 Lecture :: 1st March 37 / 43

slide-106
SLIDE 106

Diagonalization method

But D must occure in the table too! M1 M2 M3 . . . D . . . M1 reject reject accept M2 reject accept accept M3 accept accept reject . . . D ? . . . What does D do with input D? if D(D) = accept, H(D, D) = reject. This means D does not accept D(D), i.e., D(D) = reject. if D(D) = reject, H(D, D) = accept. This means D does accept D(D), i.e., D(D) = accept.

INF2080 Lecture :: 1st March 37 / 43

slide-107
SLIDE 107

Acceptance problem - TMs

Let’s formalize this: Theorem The language ATM is not decidable.

INF2080 Lecture :: 1st March 38 / 43

slide-108
SLIDE 108

Acceptance problem - TMs

Let’s formalize this: Theorem The language ATM is not decidable. Proof: Assume it is decidable. Then there exists a decider H that decides ATM. So H(M, w) = accept iff M accepts w and H(M, w) = reject iff M fails to accept w.

INF2080 Lecture :: 1st March 38 / 43

slide-109
SLIDE 109

Acceptance problem - TMs

Let’s formalize this: Theorem The language ATM is not decidable. Proof: Assume it is decidable. Then there exists a decider H that decides ATM. So H(M, w) = accept iff M accepts w and H(M, w) = reject iff M fails to accept w. We define a decider D that on input M flips the result of H(M, M). D = On input M 1. Simulate H on M, M. 2. If H accepts, reject; if H rejects, accept.

INF2080 Lecture :: 1st March 38 / 43

slide-110
SLIDE 110

Acceptance problem - TMs

Let’s formalize this: Theorem The language ATM is not decidable. Proof: Assume it is decidable. Then there exists a decider H that decides ATM. So H(M, w) = accept iff M accepts w and H(M, w) = reject iff M fails to accept w. We define a decider D that on input M flips the result of H(M, M). D = On input M 1. Simulate H on M, M. 2. If H accepts, reject; if H rejects, accept. if H accepts, D rejects and if H rejects, D accepts.

INF2080 Lecture :: 1st March 38 / 43

slide-111
SLIDE 111

Acceptance problem - TMs

Theorem The language ATM is not decidable. Proof: D = On input M 1. Simulate H on M, M. 2. If H accepts, reject; if H rejects, accept.

INF2080 Lecture :: 1st March 39 / 43

slide-112
SLIDE 112

Acceptance problem - TMs

Theorem The language ATM is not decidable. Proof: D = On input M 1. Simulate H on M, M. 2. If H accepts, reject; if H rejects, accept. So what is the result of D(D)?

INF2080 Lecture :: 1st March 39 / 43

slide-113
SLIDE 113

Acceptance problem - TMs

Theorem The language ATM is not decidable. Proof: D = On input M 1. Simulate H on M, M. 2. If H accepts, reject; if H rejects, accept. So what is the result of D(D)? Remember, H(M, w) accepts iff M(w) = accept.

INF2080 Lecture :: 1st March 39 / 43

slide-114
SLIDE 114

Acceptance problem - TMs

Theorem The language ATM is not decidable. Proof: D = On input M 1. Simulate H on M, M. 2. If H accepts, reject; if H rejects, accept. So what is the result of D(D)? Remember, H(M, w) accepts iff M(w) = accept. If D(D) = reject, then H(D, D) = accept, i.e., D(D) = accept. Contradiction!

INF2080 Lecture :: 1st March 39 / 43

slide-115
SLIDE 115

Acceptance problem - TMs

Theorem The language ATM is not decidable. Proof: D = On input M 1. Simulate H on M, M. 2. If H accepts, reject; if H rejects, accept. So what is the result of D(D)? Remember, H(M, w) accepts iff M(w) = accept. If D(D) = reject, then H(D, D) = accept, i.e., D(D) = accept. Contradiction! If D(D) = accept, then H(D, D) = reject, i.e., D(D) = reject. Contradiction!

INF2080 Lecture :: 1st March 39 / 43

slide-116
SLIDE 116

Acceptance problem - TMs

Theorem The language ATM is not decidable. Proof: D = On input M 1. Simulate H on M, M. 2. If H accepts, reject; if H rejects, accept. So what is the result of D(D)? Remember, H(M, w) accepts iff M(w) = accept. If D(D) = reject, then H(D, D) = accept, i.e., D(D) = accept. Contradiction! If D(D) = accept, then H(D, D) = reject, i.e., D(D) = reject. Contradiction! Hence neither D nor H can exist! → ATM is undecidable!

INF2080 Lecture :: 1st March 39 / 43

slide-117
SLIDE 117

Turing unrecognizability

So we’ve seen there exists an undecidable language: ATM Do there exist non-Turing-recognizable languages?

INF2080 Lecture :: 1st March 40 / 43

slide-118
SLIDE 118

Turing unrecognizability

Theorem A language A is decidable iff it is Turing-recognizable and co-Turing-recognizable, i.e., if A and its complement A are Turing-recognizable.

INF2080 Lecture :: 1st March 41 / 43

slide-119
SLIDE 119

Turing unrecognizability

Theorem A language A is decidable iff it is Turing-recognizable and co-Turing-recognizable, i.e., if A and its complement A are Turing-recognizable. Proof: If A is decidable, then it is Turing-recognizable. Since decidable langauges are closed under complementation, this means A is decidable, in particular Turing-recognizable.

INF2080 Lecture :: 1st March 41 / 43

slide-120
SLIDE 120

Turing unrecognizability

Theorem A language A is decidable iff it is Turing-recognizable and co-Turing-recognizable, i.e., if A and its complement A are Turing-recognizable. Proof: Now assume A and A are Turing recognizable. Then there exist recognizers MA and MA that accept w if it is in A or A, respectively.

INF2080 Lecture :: 1st March 42 / 43

slide-121
SLIDE 121

Turing unrecognizability

Theorem A language A is decidable iff it is Turing-recognizable and co-Turing-recognizable, i.e., if A and its complement A are Turing-recognizable. Proof: Now assume A and A are Turing recognizable. Then there exist recognizers MA and MA that accept w if it is in A or A, respectively. we combine these to a machine M: M = On input w 1. Run both MA and MA in parallel on input w 2. If MA accepts, accept; if MA accepts, reject.

INF2080 Lecture :: 1st March 42 / 43

slide-122
SLIDE 122

Turing-unrecongizability

Theorem A language A is decidable iff it is Turing-recognizable and co-Turing-recognizable, i.e., if A and its complement A are Turing-recognizable. We can use this result to show that ATM is not Turing-recognizable:

INF2080 Lecture :: 1st March 43 / 43

slide-123
SLIDE 123

Turing-unrecongizability

Theorem A language A is decidable iff it is Turing-recognizable and co-Turing-recognizable, i.e., if A and its complement A are Turing-recognizable. We can use this result to show that ATM is not Turing-recognizable: ATM is Turing-recognizable

INF2080 Lecture :: 1st March 43 / 43

slide-124
SLIDE 124

Turing-unrecongizability

Theorem A language A is decidable iff it is Turing-recognizable and co-Turing-recognizable, i.e., if A and its complement A are Turing-recognizable. We can use this result to show that ATM is not Turing-recognizable: ATM is Turing-recognizable If ATM were Turing-recognizable, then by the last theorem ATM must be decidable

INF2080 Lecture :: 1st March 43 / 43

slide-125
SLIDE 125

Turing-unrecongizability

Theorem A language A is decidable iff it is Turing-recognizable and co-Turing-recognizable, i.e., if A and its complement A are Turing-recognizable. We can use this result to show that ATM is not Turing-recognizable: ATM is Turing-recognizable If ATM were Turing-recognizable, then by the last theorem ATM must be decidable But we just saw that ATM is undecidable. Hence ATM must be Turing-unrecognizable

INF2080 Lecture :: 1st March 43 / 43