decidability
play

Decidability Gian Diego Tipaldi Topics Covered Investigation on - PowerPoint PPT Presentation

Theoretical Computer Science (Bridging Course) Decidability Gian Diego Tipaldi Topics Covered Investigation on what is solvable Decidable languages The halting problem Decidable Problems Acceptance problem: Decide if a


  1. Theoretical Computer Science (Bridging Course) Decidability Gian Diego Tipaldi

  2. Topics Covered  Investigation on what is solvable  Decidable languages  The halting problem

  3. Decidable Problems  Acceptance problem:  Decide if a string is accepted  Equivalence problem:  Decide if two automata are equivalent  Emptiness test problem:  Decide if the accepted language is empty  Applied to DFA,NFA,RE,PDA,CFG,TM,…

  4. Acceptance problem for DFAs  Decide is a DFA accept a string w  Express it as a language 𝐵 𝐸𝐺𝐵 𝐶 is a DFA that accepts 𝑥 𝐵 𝐸𝐺𝐵 = 𝐶, 𝑥  B is the encoding of a DFA  Testing acceptance is equivalent to language membership

  5. Acceptance problem for DFAs  Use a decider to test membership  Idea: Decider will simulate B and accept/reject if B accepts/rejects w  Encoding of B = (𝑅, Σ, 𝜀, 𝑟 𝑝 , 𝐺) and w q0 q1 q2 q3 # 0 1 # <table> … # q0 # q2 q3 # # 0 1 1 0 1 1 1 0 # q0

  6. Acceptance problem for DFAs  Use a decider to test membership  Idea: Decider will simulate B and accept/reject if B accepts/rejects w  Encoding of B = (𝑅, Σ, 𝜀, 𝑟 𝑝 , 𝐺) and w q0 q1 q2 q3 # 0 1 # <table> … # q0 # q2 q3 # # 0 1 1 0 1 1 1 0 # q0

  7. Acceptance problem for DFAs  Use a decider to test membership  Idea: Decider will simulate B and accept/reject if B accepts/rejects w  Encoding of B = (𝑅, Σ, 𝜀, 𝑟 𝑝 , 𝐺) and w q0 q1 q2 q3 # 0 1 # <table> … # q0 # q2 q3 # # 0 1 1 0 1 1 1 0 # q0

  8. Acceptance problem for DFAs  Use a decider to test membership  Idea: Decider will simulate B and accept/reject if B accepts/rejects w  Encoding of B = (𝑅, Σ, 𝜀, 𝑟 𝑝 , 𝐺) and w q0 q1 q2 q3 # 0 1 # <table> … # q0 # q2 q3 # # 0 1 1 0 1 1 1 0 # q0

  9. Acceptance problem for DFAs  Use a decider to test membership  Idea: Decider will simulate B and accept/reject if B accepts/rejects w  Encoding of B = (𝑅, Σ, 𝜀, 𝑟 𝑝 , 𝐺) and w q0 q1 q2 q3 # 0 1 # <table> … # q0 # q2 q3 # # 0 1 1 0 1 1 1 0 # q0

  10. Acceptance problem for DFAs  Use a decider to test membership  Idea: Decider will simulate B and accept/reject if B accepts/rejects w  Encoding of B = (𝑅, Σ, 𝜀, 𝑟 𝑝 , 𝐺) and w q0 q1 q2 q3 # 0 1 # <table> … # q0 # q2 q3 # # 0 1 1 0 1 1 1 0 # q0

  11. Acceptance problem for DFAs  Use a decider to test membership  Idea: Decider will simulate B and accept/reject if B accepts/rejects w  Encoding of B = (𝑅, Σ, 𝜀, 𝑟 𝑝 , 𝐺) and w q0 q1 q2 q3 # 0 1 # <table> … # q0 # q2 q3 # # 0 1 1 0 1 1 1 0 # q0

  12. Acceptance problem for DFAs  Use a decider to test membership  Idea: Decider will simulate B and accept/reject if B accepts/rejects w  Encoding of B = (𝑅, Σ, 𝜀, 𝑟 𝑝 , 𝐺) and w q0 q1 q2 q3 # 0 1 # <table> … # q0 # q2 q3 # # 0 1 1 0 1 1 1 0 # q0

  13. Acceptance problem for DFAs Theorem 4.1 : 𝐵 𝐸𝐺𝐵 is a decidable language. Proof: M= “On input 𝐶, 𝑥 , where 𝐶 is a DFA and 𝑥 is a string: 1.Simulate 𝐶 on input 𝑥 . 2.If the simulation ends in an accept state, accept. If it ends in a nonaccepting state, reject .”

  14. Acceptance problem for NFAs Theorem 4.2 : 𝐵 𝑂𝐺𝐵 is a decidable language. Proof: N = “On input 𝐶, 𝑥 , where 𝐶 is a NFA and 𝑥 is a string: 1.Convert the NFA in an equivalent DFA 𝐷 2.Run the previous machine on input 〈𝐷, 𝑥〉 3.If the simulation ends in an accept state, accept. If it ends in a nonaccepting state, reject .”

  15. Acceptance problem for REs Theorem 4.3 : 𝐵 𝑆𝐹 is a decidable language. Proof: P = “On input 𝐶, 𝑥 , where 𝐶 is a RE and 𝑥 is a string: 1.Convert the RE in an equivalent NFA 𝐵 2.Run the machine N on input 〈𝐵, 𝑥〉 3.If N accepts, accept. If N rejects, reject .”

  16. Emptiness problem for DFAs  Decide is a DFA accept the empty language  Express it as a language 𝐹 𝐸𝐺𝐵 𝐵 is a DFA for which 𝑀 𝐵 = ∅ 𝐹 𝐸𝐺𝐵 = 𝐵  A is the encoding of a DFA

  17. Emptiness problem for DFAs Theorem 4.4 : 𝐹 𝐸𝐺𝐵 is a decidable language. Proof idea: A DFA accepts some string iff it is possible to reach an accept state using valid transitions. Construct a TM T similar to the one for connected graphs

  18. Emptiness problem for DFAs Theorem 4.4 : 𝐹 𝐸𝐺𝐵 is a decidable language. Proof: T = “On input 𝐵 , where 𝐵 is a DFA: 1.Mark the start state of 𝐵 2.Repeat until no new state is marked 1.Mark a state if it has a transition to it coming from any other marked state 3.If no accept state is marked, accept. Otherwise, reject .”

  19. Equivalence Problem for DFAs Theorem 4.5 : 𝐹𝑅 𝐸𝐺𝐵 = 𝐵, 𝐶 𝐵, 𝐶 ∈ DFA, 𝑀 𝐵 = 𝑀 𝐶 is a decidable language. Proof idea: Prove the symmetric difference is empty. 𝑀 𝐷 = 𝑀 𝐶 ∩ 𝑀 𝐵 ∪ 𝑀 𝐵 ∩ 𝑀 𝐶 L(A) L(B) The symmetric difference of L(A) and L(B )

  20. Equivalence Problem for DFAs Theorem 4.5 : 𝐹𝑅 𝐸𝐺𝐵 is a decidable language. Proof: F = “On input 𝐵, 𝐶 , where 𝐵, 𝐶 are DFA: 1.Construct the DFA 𝐷 for the symmetric difference language (closure property) 2.Run TM T from Theorem 4.4 3.If T accepts, accept. If T rejects, reject .”

  21. Acceptance Problem for CFGs Theorem 4.7 : 𝐻 is a CFG that generates 𝑥 𝐵 𝐷𝐺𝐻 = 𝐻, 𝑥 is a decidable language. Proof idea: Rely on the fact that if G is in CNF, then any derivation of w has length at most 2|w| + 1. Also consider that there are only finitely many derivations of length less than n.

  22. Acceptance Problem for CFGs Theorem 4.7 : 𝐵 𝐷𝐺𝐻 is a decidable language. Proof: S = “On input 𝐻, 𝑥 , where 𝐶 is a CFG and 𝑥 is a string: 1.Convert G to a CNF 2.List all derivations with k=2n-1 steps, n is the length of w. if n=0 consider k=1. 3.If any of them generates w, accept. If not, reject .”

  23. Emptiness Problem for CFGs Theorem 4.7 : 𝐻 is a CFG for which 𝑀 𝐻 = ∅ 𝐹 𝐷𝐺𝐻 = 𝐻 is a decidable language. Proof idea: Determine for each variable whether that variable is capable to generate a string of terminals

  24. Emptiness Problem for CFGs Theorem 4.7 : 𝐹 𝐷𝐺𝐻 is a decidable language. Proof: R = “On input 𝐻 , where 𝐻 is a CFG: 1.Mark all terminal symbols in G 2.Repeat until no new variable is marked 1.Mark any variable A if G contains 𝐵 → 𝑉 1 … 𝑉 𝑙 and 𝑉 1 , … , 𝑉 𝑙 have all been marked 3.If the start symbol is marked, accept. If not, reject .”

  25. Equivalence Problem for CFGs 𝐹𝑅 𝐷𝐺𝐻 = 𝐻, 𝐼 𝐻, 𝐼 ∈ 𝐷𝐺𝐻𝑡, 𝑀 𝐻 = 𝑀 𝐼  Is it decidable?

  26. Equivalence Problem for CFGs 𝐹𝑅 𝐷𝐺𝐻 = 𝐻, 𝐼 𝐻, 𝐼 ∈ 𝐷𝐺𝐻𝑡, 𝑀 𝐻 = 𝑀 𝐼  Is it decidable? NO!  We cannot use the same method as for DFAs, since context free languages are not closed under complementation nor intersection.

  27. Decidability of CFLs Theorem 4.9 : Every context free language is decidable. Proof: Let G be a CFG for the language 𝑁 𝐻 = “On input 𝑥 : 1.Run the TM S on input 𝐻, 𝑥 2.If S accepts, accept; If S rejects, reject .”

  28. Classes of Languages

  29. Classes of Languages

  30. Classes of Languages

  31. Classes of Languages

  32. The Halting Problem  Some problems are unsolvable  Famous example: the halting problem Philosophical implication: Computers are fundamentally limited

  33. The Halting Problem 𝑁 is a TM that accepts 𝑥 𝐵 𝑈𝑁 = 𝑁, 𝑥 Theorem 4.11: 𝐵 𝑈𝑁 is undecidable Observation: 𝐵 𝑈𝑁 is Turing recognizable, thus recognizer are more powerful than deciders.

  34. The Halting Problem 𝑁 is a TM that accepts 𝑥 𝐵 𝑈𝑁 = 𝑁, 𝑥 The following machine recognizes it U = “On input 𝑁, 𝑥 , where M is a TM and w is a string 1. Simulate M on input w 2. If M ever enters the accept state, accept; if M ever enters the reject state, reject. ”

  35. Diagonalization  Developed by G. Cantor in 1873  Concerns the measure of infinite sets  Used to prove the halting problem  Do sets A and B have the same size?  If finite, one can count the elements  How about infinite sets?

  36. Diagonalization  Consider possible pairings from A to B  Consider the function 𝑔: 𝐵 → 𝐶  f is injective: 𝑔 𝑏 ≠ 𝑔 𝑐 , whenever 𝑏 ≠ 𝑐  f is surjective: ∀ 𝑐 ∈ 𝐶, ∃𝑏 ∈ 𝐵: 𝑔 𝑏 = 𝑐  f is bijective if injective and surjective  A and B have same size if ∃ 𝑔 bijective  A set is countable if size at most of ℕ

  37. Example – Even Numbers  Consider this two sets ∈ ℕ 𝐵 = 𝑏 𝑏 ∈ ℕ , 𝐶 = 𝑐 𝑐 2  Consider the function 𝑔: 𝐵 → 𝐶 𝑔 𝑜 = 2𝑜  f is a bijective function, therefore A and B have the same size and B is countable

  38. Example – Rational Numbers  Consider the set of rational numbers ℚ = 𝑛 𝑜 | 𝑛, 𝑜 ∈ ℕ  ℚ seems much larger than ℕ

Recommend


More recommend