Decidable Problems

COS3701 - Theoretical Computer Science III · Decidability and Undecidability

Decidable Problems

In theoretical computer science, a problem is considered decidable if there exists an algorithm that can provide a yes or no answer for every input in a finite amount of time. This means that there is a systematic method to determine the answer, regardless of the input size.

Understanding Decidable Problems

A decidable problem can be solved by a Turing machine that always halts (finishes its computation) after a finite number of steps. If a problem is decidable, it implies that there is a corresponding algorithm that can be implemented in a programming language, such as C++, to solve it.

Remember: A problem is decidable if there exists an algorithm that provides a yes or no answer for all possible inputs.

Examples of Decidable Problems

Let us explore some common examples of decidable problems:

1. The Membership Problem

Given a formal language L and a string w, the membership problem asks whether w is a member of L. If L is a regular language or a context-free language, this problem is decidable.

Example: Consider the language L defined by the regular expression (a|b)*. We want to determine if the string w = "abba" is in L.
  1. Construct a finite automaton (FA) that accepts the language (a|b)*.
  2. Simulate the FA on the input string "abba".
  3. The FA accepts the string, thus w is in L.

2. The Equality Problem

This problem asks whether two given finite automata accept the same language. If both automata are deterministic, the problem is decidable.

Example: Let A1 and A2 be two deterministic finite automata (DFA). To check if L(A1) = L(A2):
  1. Construct the product automaton A3 = A1 × A2.
  2. Check if A3 has any reachable states that are accepting states from both A1 and A2.
  3. If no such state exists, then L(A1) = L(A2).

3. The Halting Problem for Bounded Input

The classic halting problem asks whether a Turing machine will halt on a given input. However, if we restrict the input to a bounded length, the problem becomes decidable.

Example: Given a Turing machine M and an input w of length n, we can simulate M on w for n steps:
  1. If M halts within n steps, we conclude that M halts on w.
  2. If M does not halt within n steps, we conclude that M does not halt on w.

Watch out: The unrestricted halting problem is undecidable. Make sure to note the difference between the bounded and unbounded versions.

Properties of Decidable Problems

Decidable problems have several important properties:

  • Closure Properties: Decidable languages are closed under union, intersection, and complementation. This means that if L1 and L2 are decidable languages, then L1 ∪ L2, L1 ∩ L2, and the complement of L1 (denoted as L1') are also decidable.
  • Reduction: If problem A is reducible to problem B, and B is decidable, then A is also decidable. This technique is often used to prove the decidability of problems.

Decidability in the Chomsky Hierarchy

The Chomsky hierarchy classifies languages into four types: regular languages, context-free languages, context-sensitive languages, and recursively enumerable languages. Decidable problems are typically found in the first two categories (regular and context-free languages). Here is a brief overview:

  • Regular Languages: These languages can be represented by regular expressions and accepted by finite automata. Examples include the language of all strings over {a, b}.
  • Context-Free Languages: These languages can be generated by context-free grammars and accepted by pushdown automata. An example is the language of balanced parentheses.

Deciding Context-Free Languages

Context-free languages can be decided using a parsing algorithm. One common algorithm is the CYK (Cocke-Younger-Kasami) algorithm, which determines whether a string belongs to a context-free language defined by a given grammar.

Example: Given a context-free grammar G and a string w = "((()))":
  1. Construct the parse table using the CYK algorithm.
  2. Check if the starting symbol of G can derive the string w.

Tip: Familiarise yourself with parsing algorithms for context-free languages, as they are crucial for understanding decidability in this context.

Decidability of Recursive Languages

Recursive languages are a subset of recursively enumerable languages. A language is recursive if there exists a Turing machine that will always halt and accept strings in the language, and reject strings not in the language. All recursive languages are decidable.

Example: The language of all strings that represent valid arithmetic expressions is recursive.
  1. Design a Turing machine that checks the syntax of arithmetic expressions.
  2. The Turing machine halts and accepts valid expressions while rejecting invalid ones.

Summary

  • A problem is decidable if there is an algorithm that provides a yes or no answer for all inputs.
  • Common examples of decidable problems include the membership problem, the equality problem, and the bounded version of the halting problem.
  • Decidable languages are closed under union, intersection, and complementation.
  • Decidable problems are typically found in regular and context-free languages.

Check your understanding

  1. What is a decidable problem?
  2. Give an example of a decidable problem and explain why it is decidable.
  3. What are the closure properties of decidable languages?
  4. How does the CYK algorithm determine membership in a context-free language?