Lecture 32: language of a machine

• Definitions:
• extended transition function (δ^), L(M)
• DFA-recognizable
• Proof of correctness of a machine

• Product construction for DFA union

Definitions

Extended transition function (Note: because this doesn't render nicely in HTML, I will write δ^ for "delta-hat")

• δ^: Q × Σ * Q
• informally: δ^(q, x) tells you where you end up after processing the string x starting in state q.
• compare with δ: Q × ΣQ: δ^ processes strings, while δ processes single characters
• domain of δ is finite, so description of δ is finite; it is part of the machine.
• domain of δ is infinite, it is not part of the description of the machine (but is built from the description of the machine).
• δ^: (q, ε)↦q, and δ^: (q, xa)↦δ(δ^(q, x), a)
• informally: to process xa, first process x; starting there, take a single step with the (non-extended) transition function δ
• Note: the δ in this definition cannot be δ^

Language - A language is a set of strings

Language of a machine - L(M) stands for the "language of M". - contains all (and only) strings that M accepts - Informally, a string x is accepted by a machine M if, after processing x starting at the start state, the machine ends in a final state. - formal definition: L(M) = {xΣ *   ∣  δ^(q0, x)∈F}, where M = (Q, Σ, δ, q0, F). - We say x is accepted by M if x ∈ L(M), x is rejected otherwise. - We say that M recognizes L if L = L(M). - A language L is DFA-recognizable if there is some machine M with L = L(M).

Proving a machine correct

Given a language L, we may wish to build a machine that recognizes L, and prove that it is correct.

In other words, we wish to prove that L = L(M).

In other words, we wish to prove that xΣ * , xL if and only if xL(M).

In other words, we wish to prove that xΣ * , xL if and only if δ^(q0, x)∈F.

A straightforward approach is induction on the structure of x; however the induction hypothesis usually needs to be strengthened to describe all of the states (and not just the final state); essentially you want to prove that each state "satisfies its specification".

For example: we may want to build a machine that recognizes strings that contain at least two ones. We might build a machine with three states: q0 represents strings with no 1's, q1 represents strings with one 1, and q2 represents strings with two or more 1's.

A proof of correctness for this machine might go as follows:

Let P(x) be the statement "δ^(q0, x) = q0 if and only if x has no 1s, and δ^(q0, x) = q1 if and only if x has exactly one 1, and δ^(q0, x) = q2 if and only if x has two or more 1's. I claim that ∀ xΣ * , P(x) holds.

We will prove this claim by induction on the structure of x. We must show P(ε) and, assuming P(x), P(xa).

To prove P(ε), note that δ^(q0, ε) = q0. Thus only the first part of P(x) makes any claim (it is vacuously true that if δ^(q0, ε) = q1, then ε contains one 1, because the statement says nothing).

Now, to prove P(xa), assume P(x). a can be either 0 or 1, and δ^(q0, x) could be any of q0, q1, and q2. We consider each case:

1. If a = 0, then note that δ(qi, a) = qi. Moreover, note that xa has the same number of 1's as x. Thus in this case, P(xa) follows directly from P(x).

2. If a = 1 and δ^(q0, x) = q0, then by P(x), x must have no 1's. Thus xa has exactly one 1. Moreover, δ^(q0, xa) = δ(δ^(q0, x), a) = δ(q0, 1) = q1, so \$P(xa) holds in this case.

3. If a = 1 and δ^(q0, x) = q1, then by P(x), x\$ must have one
4. Thus xa has two ones. Moreover, δ^(q0, xa) = δ(δ^(q0, x), a) = δ(q1, 1) = q2, so \$P(xa) holds in this case.

5. If a = 1 and δ^(q0, x) = q2, then by P(x), x\$ must have two or more 1's. Thus xa has more than two ones. Moreover, δ^(q0, xa) = δ(δ^(q0, x), a) = δ(q2, 1) = q2, so \$P(xa) holds in this case.

In all possible cases, we have shown P(xa). This concludes the inductive proof.

Note that the framework provided by the inductive proof forces you to write down a specification for each state, and then reason about each transition.