← All writing

Introduction to Theory of Computation (1)

Automata and Formal Languages

Parts: 1 · 2

Zero: Introduction

This book focuses on three traditionally central areas of the theory of computation: automata, computability, and complexity. They are linked by the question:

What are the fundamental capabilities and limitations of computers?

COMPLEXITY THEORY

What makes some problems computationally hard and others easy?

This is the central question of complexity theory.

COMPUTABILITY THEORY

During the first half of the twentieth century, mathematicians such as Kurt Godel, Alan Turing, and Alonzo Church discovered that certain basic problems cannot be solved by computers.

AUTOMATA THEORY

Automata theory deals with the definitions and properties of mathematical models of computation.

Part One: Automata and Languages

Chapter One: Regular Languages

1.5 Finite automaton

A finite automaton is a 5-tuple (Q,Σ,δ,q0,F)(Q, \Sigma, \delta, q_0, F), where

  1. QQ is a finite set called the states

  2. Σ\Sigma is a finit set called the alphabat

  3. δ:Q×Σ→Q\delta: Q \times \Sigma \rarr Q is the transition function

  4. q0∈Qq_0 \in Q is the start state

  5. F⊆QF \subseteq Q is the set of accept states

accepts

Let M=(Q,Σ,δ,q0,F)M = (Q, \Sigma, \delta, q_0, F) be a finite automaton and let w=w1w2⋅⋅⋅wnw = w_1w_2 · · · w_n be a string where each wiw_i is a member of the alphabet Σ\Sigma. Then MM accepts ww if a sequence of states r0,r1,...,rnr_0, r_1, . . . , r_n in QQ exists with three conditions:

  1. r0=q0r_0 = q_0
  2. δ(ri,wi+1)=ri+1\delta(r_i, w_{i + 1}) = r_{i + 1}, for i=0,...,n−1i = 0, ..., n - 1
  3. rn∈Fr_n \in F

1.16 regular language

We say that MM recognizes language AA if A={w ∣ M accepts w}A = \{w \ | \ M \ accepts \ w\}.

A language is called a regular language if some finite automatonrecognizes it.

1.23 regular operations

Let AA and BB be languages. We defifine the regular operations union,

concatenation, and star as follows:

Union:A∪B={x∣ x∈A or x∈B}Concatenation:A∘B={xy ∣ x∈A and y∈B}Star:A∗={x1x2...xk ∣ k≥0 and ∀xi∈A}Union: A \cup B = \{x | \ x \in A \ or \ x \in B \}\\ Concatenation : A \circ B = \{xy \ | \ x \in A \ and \ y \in B\}\\ Star: A^* = \{x_1x_2...x_k \ | \ k \ge 0 \ and \ \forall x_i\in A\}

1.25 Theorem

The class of regular languages is closed under the union operation.

1.26 Theorem

The class of regular languages is closed under the concatenation operation.

1.37 Nondeterministic Finite Automaton

A nondeterministic finite automaton is a 5-tuple (Q,Σ,δ,q0,F)(Q, \Sigma, \delta, q_0, F), where

  1. QQ is a finite set called the states

  2. Σ\Sigma is a finit set called the alphabat

  3. δ:Q×Σε(Σ∪{ε})→P(Q)\delta: Q \times \Sigma_{\varepsilon}(\Sigma \cup\{\varepsilon\}) \rarr P(Q) is the transition function

  4. q0∈Qq_0 \in Q is the start state

  5. F⊆QF \subseteq Q is the set of accept states

How does an NFA compute? Suppose that we are running an NFA on an input string and come to a state with multiple ways to proceed. For example, say that we are in state q1q_1 in NFA N1N_1 and that the next input symbol is a1a_1. After readingthat symbol, the machine splits into multiple copies of itself and follows all the possibilities in parallel. Each copy of the machine takes one of the possible ways to proceed and continues as before. If there are subsequent choices, the machine splits again. If the next input symbol doesn’t appear on any of the arrows exiting the state occupied by a copy of the machine, that copy of the machine dies, along with the branch of the computation associated with it. Finally, if any one of these copies of the machine is in an accept state at the end of the input, the NFA accepts the input string.

If a state with an εε symbol on an exiting arrow is encountered, something similar happens. Without reading any input, the machine splits into multiple copies, one following each of the exiting εε-labeled arrows and one staying at the current state.

Nondeterminism may be viewed as a kind of parallel computation wherein multiple independent “processes” or “threads” can be running concurrently.

Another way to think of a nondeterministic computation is as a tree of possibilities.

Let N=(Q,Σ,δ,q0,F)N = (Q, \Sigma, \delta, q_0, F) be a finite automaton and let w=w1w2⋅⋅⋅wnw = w_1w_2 · · · w_n be a string where each wiw_i is a member of the alphabet Σε\Sigma_{\varepsilon}. Then NN accepts ww if a sequence of states r0,r1,...,rnr_0, r_1, . . . , r_n in QQ exists with three conditions:

  1. r0=q0r_0 = q_0
  2. ri+1∈δ(ri,wi+1)r_{i + 1}\in\delta(r_i, w_{i + 1}) , for i=0,...,n−1i = 0, ..., n - 1
  3. rn∈Fr_n \in F

1.39 Theorem

Say that two machines are equivalent if they recognize the same language.

Every nondeterministic fifinite automaton has an equivalent deterministic fifinite

automaton.

1.49 Theorem

The class of regular languages is closed under the star operation.

1.3 Regular Expressions

Say that RR is a regular expression if RR is

  1. aa for some aa in the alphabet Σ\Sigma

  2. ε\varepsilon

  3. ∅\empty

  4. (R1∪R2)(R_1 \cup R_2), where R1R_1 and R2R_2 are regular expressions

  5. (R1∘R2)(R_1 \circ R_2), where R1R_1 and R2R_2 are regular expressions

  6. (R1∗)(R_1^*), where R1R_1 is a regular expressions

When we want to distinguish between a regular expression RR and the language that it describes, we write L(R)L(R) to be the language of RR.

NOTE:

n items 1 and 2, the regular expressions aa and εε represent the languages {a}\{a\} and {ε}\{ε\}, respectively.

in item 3, the regular expression ∅∅ represents the empty language.

Thus regular expression is some operating expression on set.

Don’t confuse the regular expressions εε and ∅∅. The expression εε represents the language containing a single string—namely, the empty string—whereas ∅∅ represents the language that doesn’t contain any strings.

1.54 Thorem

A language is regular if and only if some regular expression describes it.

1.64 Generalized Nondeterministic Finite Automaton

A generalized nondeterministic finite automaton is a 5-tuple (Q,Σ,δ,qstart,qaccept)(Q, \Sigma, \delta, q_{start}, q_{accept}), where

  1. QQ is a finite set called the states

  2. Σ\Sigma is the input alphabat

  3. δ:(Q−{qaccept})×(Q−{qstart})→R\delta: (Q-\{q_{accept}\}) \times (Q-\{q_{start}\}) \rarr R is the transition function

  4. qstartq_{start} is the start state

  5. qacceptq_{accept} is the accept state

1.4 Nonregular Language

1.70 Pumping Lemma

If AA is a regular language, then there is a number pp (thepumping length) where if ss is any string in AA of length at least pp, then ss may bedivided into three pieces, s=xyzs = xyz, satisfying the following conditions:

  1. for each i≥0,xyiz∈Ai \ge 0, xy^iz \in A
  2. ∣y∣>0|y| > 0
  3. ∣xy∣≤p|xy| \le p

Chapter Two: Context-free Languages

2.2 Context-free Grammar (CFG)

A context-free grammar is a 4-tuple (V,Σ,R,S)(V, \Sigma, R, S), where

  1. VV is a finite set, called the variables

  2. Σ\Sigma is a finite set, disjoint from VV, called the terminals

  3. RR is a finite set of rules, with each rule being a variable and a string of variables and terminals

  4. S∈VS \in V is the start variable

2.7 Ambiguous

AA string ww is derived ambiguously in context-free grammar GG if it has two or more different leftmost derivations. Grammar GG is ambiguous if it generates some string ambiguously.

2.8 Chomsky Normal Form

A context-free grammar is in Chomsky normal form if every rule is of the form

A→BCA→aA \rarr BC\\ A \rarr a

where a is any terminal and AA, BB, and CC are any variables—except that BB and CC may not be the start variable. In addition, we permit the rule S→εS \rarr \varepsilon, where SS is the start variable.

2.9 Theorem

Any context-free language is generated by a context-free grammar in Chomsky normal form.

2.13 Pushdown Automaton

A pushdown automaton is a 6-tuple (Q,Σ,Γ,δ,q0,F)(Q, \Sigma, \Gamma, \delta, q_0, F), where Q,Σ,ΓQ, \Sigma, \Gamma, and FF are all finite sets, and

  1. QQ is the set of states

  2. Σ\Sigma is the input alphabet

  3. Γ\Gamma is the stack alphabet

  4. δ:Q×Σε×Γε→P(Q×Γε)\delta : Q \times \Sigma_{\varepsilon} \times \Gamma_{\varepsilon} \rarr P(Q \times \Gamma_{\varepsilon}) is the transiton function

  5. q0∈Qq_0 \in Q is the start states

  6. F⊆QF \subseteq Q is the set of accept states

A pushdown automaton M=(Q,Σ,Γ,δ,q0,F)M = (Q, \Sigma, \Gamma, \delta, q_0, F) computes as follows. It accepts input w if w can be written as w=w1w2⋅⋅⋅wmw = w_1w_2 · · · w_m, where each wi∈Σεw_i\in \Sigma_{\varepsilon} andsequences of states r0,r1,...,rm∈Qr_0, r_1, . . . , r_m \in Q and strings s0,s1,...,sm∈Γ∗s_0, s_1, . . . , s_m \in \Gamma^* exist that satisfy the following three conditions. The strings sis_i represent the sequence of stack contents that MM has on the accepting branch of the computation.

  1. .r0=q0 and s0=εr_0 = q_0 \ and \ s_0 = \varepsilon. This condition signifies that M starts out properly, in the start state and with an empty stack.
  2. Fori=0,...,m−1 i = 0, . . . , m-1, we have (ri+1,b)∈δ(ri,wi+1,a)(r_{i+1}, b) \in \delta(r_i, w_{i+1}, a), where si=at si_ = at and si+1=bts_{i+1} = bt for some a,b∈Γεa, b \in \Gamma_{\varepsilon} and t∈Γ∗t \in \Gamma^*. This condition states that MMmoves properly according to the state, stack, and next input symbol.
  3. rm∈Fr_m \in F. This condition states that an accept state occurs at the input end.

2.20 Theorem

A language is context free if and only if some pushdown automaton recognizes it.

Every regular language is context free.

2.34 Pumping Lemma for Context-free Languages

If AA is a context-free language, then there is a number pp (the pumping length) where, if s is any string in AA of length at least pp, then ss may be divided into five pieces s=uvxyzs = uvxyz satisfying the conditions

  1. for each i≥0, uvixyiz∈Ai \ge0, \ uv^ixy^iz \in A
  2. ∣vy∣>0|vy| > 0
  3. ∣vxy∣≤p|vxy| \le p

2.39 Deterministic Pushdown Automaton

A deterministic pushdown automaton is a 6-tuple (Q,Σ,Γ,δ,q0,F)(Q, \Sigma, \Gamma, \delta, q_0, F), where Q,Σ,ΓQ, \Sigma, \Gamma, and FF are all finite sets, and

  1. QQ is the set of states

  2. Σ\Sigma is the input alphabet

  3. Γ\Gamma is the stack alphabet

  4. δ:Q×Σε×Γε→Q×Γε∪{∅}\delta : Q \times \Sigma_{\varepsilon} \times \Gamma_{\varepsilon} \rarr Q \times \Gamma_{\varepsilon} \cup \{\empty \} is the transiton function

  5. q0∈Qq_0 \in Q is the start states

  6. F⊆QF \subseteq Q is the set of accept states

The transition function δ\delta must satisfy the following condition. For every q∈Q,a∈Σ,and x∈Γq \in Q, a \in \Sigma, and \ x \in \Gamma , exactly one of the values

δ(q,a,x),δ(q,a,ε),δ(q,ε,x),δ(q,ε,ε)\delta(q,a,x), \delta(q,a,\varepsilon), \delta(q,\varepsilon,x), \delta(q,\varepsilon,\varepsilon)

is not ∅\empty

2.41 Lemma

Every DPDA has an equivalent DPDA that always reads the entire input string. A DPDA may fail to read the entire input if it tries to pop an empty stack or because it makes an endless sequence of ε-input moves.

2.42 Theorem

The class of DCFLs is closed under complementation.

2.43 Theorem

A is a DCFL if and only if A⊣A\dashv is a DCFL.

we will occasionally consider endmarked inputs whereby the special endmarker symbol ⊣\dashv is appended to the input string.

2.47 Deterministic Context-free Grammar

A deterministic context-free grammar is a context-free grammar such that every valid string has a forced handle.

2.57 Theorem

An endmarked language is generated by a deterministic context-free grammar if and only if it is deterministic context free.

2.62 LR(k)LR(k) Grammar

An LR(k)LR(k) grammar is a context-free grammar such that the handle of every valid string is forced by lookahead kk.


Next →

← Back to ArchiveBack to top ↑

Comments

No approved comments yet.

Your display name and plain-text comment become public only after owner approval. No account or email is required.