100% found this document useful (2 votes)
28 views55 pages

Instant Access To Notes On Formal Languages Automata Computability and Complexity Gallier J Ebook Full Chapters

complexity

Uploaded by

wakilobear84
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
28 views55 pages

Instant Access To Notes On Formal Languages Automata Computability and Complexity Gallier J Ebook Full Chapters

complexity

Uploaded by

wakilobear84
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 55

Download the Full Version of textbook for Fast Typing at textbookfull.

com

Notes on formal languages automata computability


and complexity Gallier J

https://textbookfull.com/product/notes-on-formal-languages-
automata-computability-and-complexity-gallier-j/

OR CLICK BUTTON

DOWNLOAD NOW

Download More textbook Instantly Today - Get Yours Now at textbookfull.com


Recommended digital products (PDF, EPUB, MOBI) that
you can download immediately if you are interested.

Automata and Computability: A Programmer’s Perspective


Ganesh Gopalakrishnan

https://textbookfull.com/product/automata-and-computability-a-
programmers-perspective-ganesh-gopalakrishnan/

textboxfull.com

Research on Tibetan Spelling Formal Language and Automata


with Application Nyima Tashi

https://textbookfull.com/product/research-on-tibetan-spelling-formal-
language-and-automata-with-application-nyima-tashi/

textboxfull.com

Groups Languages and Automata 1st Edition Derek F. Holt

https://textbookfull.com/product/groups-languages-and-automata-1st-
edition-derek-f-holt/

textboxfull.com

Fundamentals of linear algebra and optimization Gallier J.

https://textbookfull.com/product/fundamentals-of-linear-algebra-and-
optimization-gallier-j/

textboxfull.com
Basics of algebra topology and differential calculus
Gallier J

https://textbookfull.com/product/basics-of-algebra-topology-and-
differential-calculus-gallier-j/

textboxfull.com

Differential geometry and Lie groups A computational


perspective Gallier J.

https://textbookfull.com/product/differential-geometry-and-lie-groups-
a-computational-perspective-gallier-j/

textboxfull.com

Mathematical foundations of automata theory Pin J.-E

https://textbookfull.com/product/mathematical-foundations-of-automata-
theory-pin-j-e/

textboxfull.com

Fundamentals of optimization theory with applications to


machine learning Gallier J.

https://textbookfull.com/product/fundamentals-of-optimization-theory-
with-applications-to-machine-learning-gallier-j/

textboxfull.com

Fundamentals of optimization theory with applications to


machine learning Gallier J.

https://textbookfull.com/product/fundamentals-of-optimization-theory-
with-applications-to-machine-learning-gallier-j-2/

textboxfull.com
Introduction to the Theory of Computation
Some Notes for CIS511

Jean Gallier
Department of Computer and Information Science
University of Pennsylvania
Philadelphia, PA 19104, USA
e-mail: [email protected]

c Jean Gallier
Please, do not reproduce without permission of the author

December 21, 2018


Contents

1 Introduction 7

2 Basics of Formal Language Theory 9


2.1 Alphabets, Strings, Languages . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.2 Operations on Languages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

3 DFA’s, NFA’s, Regular Languages 19


3.1 Deterministic Finite Automata (DFA’s) . . . . . . . . . . . . . . . . . . . . . 20
3.2 The “Cross-product” Construction . . . . . . . . . . . . . . . . . . . . . . . 25
3.3 Nondeteterministic Finite Automata (NFA’s) . . . . . . . . . . . . . . . . . . 27
3.4 ǫ-Closure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
3.5 Converting an NFA into a DFA . . . . . . . . . . . . . . . . . . . . . . . . . 32
3.6 Finite State Automata With Output: Transducers . . . . . . . . . . . . . . . 36
3.7 An Application of NFA’s: Text Search . . . . . . . . . . . . . . . . . . . . . 40

4 Hidden Markov Models (HMMs) 45


4.1 Hidden Markov Models (HMMs) . . . . . . . . . . . . . . . . . . . . . . . . . 45
4.2 The Viterbi Algorithm and the Forward Algorithm . . . . . . . . . . . . . . 58

5 Regular Languages, Minimization of DFA’s 67


5.1 Morphisms, F -Maps, B-Maps and Homomorphisms of DFA’s . . . . . . . . . 67
5.2 Directed Graphs and Paths . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
5.3 Labeled Graphs and Automata . . . . . . . . . . . . . . . . . . . . . . . . . 75
5.4 The Closure Definition of the Regular Languages . . . . . . . . . . . . . . . 77
5.5 Regular Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
5.6 Regular Expressions and Regular Languages . . . . . . . . . . . . . . . . . . 81
5.7 Regular Expressions and NFA’s . . . . . . . . . . . . . . . . . . . . . . . . . 83
5.8 Right-Invariant Equivalence Relations on Σ∗ . . . . . . . . . . . . . . . . . . 91
5.9 Finding minimal DFA’s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
5.10 State Equivalence and Minimal DFA’s . . . . . . . . . . . . . . . . . . . . . 104
5.11 The Pumping Lemma . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
5.12 A Fast Algorithm for Checking State Equivalence . . . . . . . . . . . . . . . 118

6 Context-Free Grammars And Languages 131

2
CONTENTS 3

6.1 Context-Free Grammars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131


6.2 Derivations and Context-Free Languages . . . . . . . . . . . . . . . . . . . . 132
6.3 Normal Forms for Context-Free Grammars . . . . . . . . . . . . . . . . . . . 138
6.4 Regular Languages are Context-Free . . . . . . . . . . . . . . . . . . . . . . 145
6.5 Useless Productions in Context-Free Grammars . . . . . . . . . . . . . . . . 146
6.6 The Greibach Normal Form . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
6.7 Least Fixed-Points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
6.8 Context-Free Languages as Least Fixed-Points . . . . . . . . . . . . . . . . . 151
6.9 Least Fixed-Points and the Greibach Normal Form . . . . . . . . . . . . . . 155
6.10 Tree Domains and Gorn Trees . . . . . . . . . . . . . . . . . . . . . . . . . . 160
6.11 Derivations Trees . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
6.12 Ogden’s Lemma . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166
6.13 Pushdown Automata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172
6.14 From Context-Free Grammars To PDA’s . . . . . . . . . . . . . . . . . . . . 176
6.15 From PDA’s To Context-Free Grammars . . . . . . . . . . . . . . . . . . . . 177
6.16 The Chomsky-Schutzenberger Theorem . . . . . . . . . . . . . . . . . . . . . 179

7 A Survey of LR-Parsing Methods 181


7.1 LR(0)-Characteristic Automata . . . . . . . . . . . . . . . . . . . . . . . . . 181
7.2 Shift/Reduce Parsers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190
7.3 Computation of FIRST . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192
7.4 The Intuition Behind the Shift/Reduce Algorithm . . . . . . . . . . . . . . . 193
7.5 The Graph Method for Computing Fixed Points . . . . . . . . . . . . . . . . 194
7.6 Computation of FOLLOW . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196
7.7 Algorithm T raverse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197
7.8 More on LR(0)-Characteristic Automata . . . . . . . . . . . . . . . . . . . . 199
7.9 LALR(1)-Lookahead Sets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199
7.10 Computing FIRST, FOLLOW, etc. in the Presence of ǫ-Rules . . . . . . . . 201
7.11 LR(1)-Characteristic Automata . . . . . . . . . . . . . . . . . . . . . . . . . 208

8 RAM Programs, Turing Machines 213


8.1 Partial Functions and RAM Programs . . . . . . . . . . . . . . . . . . . . . 213
8.2 Definition of a Turing Machine . . . . . . . . . . . . . . . . . . . . . . . . . . 219
8.3 Computations of Turing Machines . . . . . . . . . . . . . . . . . . . . . . . . 221
8.4 RAM-computable functions are Turing-computable . . . . . . . . . . . . . . 224
8.5 Turing-computable functions are RAM-computable . . . . . . . . . . . . . . 225
8.6 Computably Enumerable and Computable Languages . . . . . . . . . . . . . 226
8.7 The Primitive Recursive Functions . . . . . . . . . . . . . . . . . . . . . . . 227
8.8 The Partial Computable Functions . . . . . . . . . . . . . . . . . . . . . . . 233

9 Universal RAM Programs and the Halting Problem 239


9.1 Pairing Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
9.2 Equivalence of Alphabets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242
4 CONTENTS

9.3 Coding of RAM Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246


9.4 Kleene’s T -Predicate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254
9.5 A Simple Function Not Known to be Computable . . . . . . . . . . . . . . . 256
9.6 A Non-Computable Function; Busy Beavers . . . . . . . . . . . . . . . . . . 258

10 Elementary Recursive Function Theory 263


10.1 Acceptable Indexings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263
10.2 Undecidable Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266
10.3 Listable (Recursively Enumerable) Sets . . . . . . . . . . . . . . . . . . . . . 271
10.4 Reducibility and Complete Sets . . . . . . . . . . . . . . . . . . . . . . . . . 276
10.5 The Recursion Theorem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280
10.6 Extended Rice Theorem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284
10.7 Creative and Productive Sets . . . . . . . . . . . . . . . . . . . . . . . . . . 287

11 Listable and Diophantine Sets; Hilbert’s Tenth 291


11.1 Diophantine Equations; Hilbert’s Tenth Problem . . . . . . . . . . . . . . . . 291
11.2 Diophantine Sets and Listable Sets . . . . . . . . . . . . . . . . . . . . . . . 294
11.3 Some Applications of the DPRM Theorem . . . . . . . . . . . . . . . . . . . 298

12 The Post Correspondence Problem; Applications 303


12.1 The Post Correspondence Problem . . . . . . . . . . . . . . . . . . . . . . . 303
12.2 Some Undecidability Results for CFG’s . . . . . . . . . . . . . . . . . . . . . 304
12.3 More Undecidable Properties of Languages . . . . . . . . . . . . . . . . . . . 307

13 Computational Complexity; P and N P 309


13.1 The Class P . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309
13.2 Directed Graphs, Paths . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 311
13.3 Eulerian Cycles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 312
13.4 Hamiltonian Cycles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 313
13.5 Propositional Logic and Satisfiability . . . . . . . . . . . . . . . . . . . . . . 314
13.6 The Class N P, N P-Completeness . . . . . . . . . . . . . . . . . . . . . . . 318
13.7 The Cook-Levin Theorem . . . . . . . . . . . . . . . . . . . . . . . . . . . . 323

14 Some N P-Complete Problems 335


14.1 Statements of the Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . 335
14.2 Proofs of N P-Completeness . . . . . . . . . . . . . . . . . . . . . . . . . . . 346
14.3 Succinct Certificates, coN P, and EX P . . . . . . . . . . . . . . . . . . . . . 359

15 Primality Testing is in N P 365


15.1 Prime Numbers and Composite Numbers . . . . . . . . . . . . . . . . . . . . 365
15.2 Methods for Primality Testing . . . . . . . . . . . . . . . . . . . . . . . . . . 366
15.3 Modular Arithmetic, the Groups Z/nZ, (Z/nZ)∗ . . . . . . . . . . . . . . . . 369
15.4 The Lucas Theorem; Lucas Trees . . . . . . . . . . . . . . . . . . . . . . . . 378
CONTENTS 5

15.5 Algorithms for Computing Powers Modulo m . . . . . . . . . . . . . . . . . 383


15.6 PRIMES is in N P . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 385

16 Phrase-Structure and Context-Sensitive Grammars 389


16.1 Phrase-Structure Grammars . . . . . . . . . . . . . . . . . . . . . . . . . . . 389
16.2 Derivations and Type-0 Languages . . . . . . . . . . . . . . . . . . . . . . . 390
16.3 Type-0 Grammars and Context-Sensitive Grammars . . . . . . . . . . . . . . 391
6 CONTENTS
Chapter 1

Introduction

The theory of computation is concerned with algorithms and algorithmic systems: their
design and representation, their completeness, and their complexity.
The purpose of these notes is to introduce some of the basic notions of the theory of
computation, including concepts from formal languages and automata theory, the theory of
computability, some basics of recursive function theory, and an introduction to complexity
theory. Other topics such as correctness of programs will not be treated here (there just
isn’t enough time!).
The notes are divided into three parts. The first part is devoted to formal languages
and automata. The second part deals with models of computation, recursive functions, and
undecidability. The third part deals with computational complexity, in particular the classes
P and N P.

7
8 CHAPTER 1. INTRODUCTION
Chapter 2

Basics of Formal Language Theory

2.1 Alphabets, Strings, Languages


Our view of languages is that a language is a set of strings. In turn, a string is a finite
sequence of letters from some alphabet. These concepts are defined rigorously as follows.
Definition 2.1. An alphabet Σ is any finite set.

We often write Σ = {a1 , . . . , ak }. The ai are called the symbols of the alphabet.
Examples:
Σ = {a}
Σ = {a, b, c}
Σ = {0, 1}
Σ = {α, β, γ, δ, ǫ, λ, ϕ, ψ, ω, µ, ν, ρ, σ, η, ξ, ζ}
A string is a finite sequence of symbols. Technically, it is convenient to define strings as
functions. For any integer n ≥ 1, let

[n] = {1, 2, . . . , n},

and for n = 0, let


[0] = ∅.
Definition 2.2. Given an alphabet Σ, a string over Σ (or simply a string) of length n is
any function

u : [n] → Σ.

The integer n is the length of the string u, and it is denoted as |u|. When n = 0, the
special string
u : [0] → Σ of length 0 is called the empty string, or null string, and is denoted as ǫ.

9
10 CHAPTER 2. BASICS OF FORMAL LANGUAGE THEORY

Given a string u : [n] → Σ of length n ≥ 1, u(i) is the i-th letter in the string u. For
simplicity of notation, we denote the string u as

u = u1 u2 . . . un ,

with each ui ∈ Σ.
For example, if Σ = {a, b} and u : [3] → Σ is defined such that u(1) = a, u(2) = b, and
u(3) = a, we write
u = aba.

Other examples of strings are

work, f un, gabuzomeuh

Strings of length 1 are functions u : [1] → Σ simply picking some element u(1) = ai in Σ.
Thus, we will identify every symbol ai ∈ Σ with the corresponding string of length 1.
The set of all strings over an alphabet Σ, including the empty string, is denoted as Σ∗ .
Observe that when Σ = ∅, then
∅∗ = {ǫ}.
When Σ 6= ∅, the set Σ∗ is countably infinite. Later on, we will see ways of ordering and
enumerating strings.
Strings can be juxtaposed, or concatenated.

Definition 2.3. Given an alphabet Σ, given any two strings u : [m] → Σ and v : [n] → Σ,
the concatenation u · v (also written uv) of u and v is the string
uv : [m + n] → Σ, defined such that

u(i) if 1 ≤ i ≤ m,
uv(i) =
v(i − m) if m + 1 ≤ i ≤ m + n.

In particular, uǫ = ǫu = u. Observe that

|uv| = |u| + |v|.

For example, if u = ga, and v = buzo, then

uv = gabuzo

It is immediately verified that

u(vw) = (uv)w.
2.1. ALPHABETS, STRINGS, LANGUAGES 11

Thus, concatenation is a binary operation on Σ∗ which is associative and has ǫ as an identity.


Note that generally, uv 6= vu, for example for u = a and v = b.
Given a string u ∈ Σ∗ and n ≥ 0, we define un recursively as follows:

u0 = ǫ
un+1 = un u (n ≥ 0).

Clearly, u1 = u, and it is an easy exercise to show that


un u = uun , for all n ≥ 0.
For the induction step, we have

un+1 u = (un u)u by definition of un+1


= (uun )u by the induction hypothesis
= u(un u) by associativity
= uun+1 by definition of un+1 .
Definition 2.4. Given an alphabet Σ, given any two strings u, v ∈ Σ∗ we define the following
notions as follows:
u is a prefix of v iff there is some y ∈ Σ∗ such that
v = uy.

u is a suffix of v iff there is some x ∈ Σ∗ such that


v = xu.

u is a substring of v iff there are some x, y ∈ Σ∗ such that


v = xuy.

We say that u is a proper prefix (suffix, substring) of v iff u is a prefix (suffix, substring)
of v and u 6= v.
For example, ga is a prefix of gabuzo,
zo is a suffix of gabuzo and
buz is a substring of gabuzo.
Recall that a partial ordering ≤ on a set S is a binary relation ≤ ⊆ S × S which is
reflexive, transitive, and antisymmetric.
The concepts of prefix, suffix, and substring, define binary relations on Σ∗ in the obvious
way. It can be shown that these relations are partial orderings.
Another important ordering on strings is the lexicographic (or dictionary) ordering.
12 CHAPTER 2. BASICS OF FORMAL LANGUAGE THEORY

Definition 2.5. Given an alphabet Σ = {a1 , . . . , ak } assumed totally ordered such that
a1 < a2 < · · · < ak , given any two strings u, v ∈ Σ∗ , we define the lexicographic ordering 
as follows:

 (1) if v = uy, for some y ∈ Σ∗ , or
uv (2) if u = xai y, v = xaj z, ai < aj ,

with ai , aj ∈ Σ, and for some x, y, z ∈ Σ∗ .

Note that cases (1) and (2) are mutually exclusive. In case (1) u is a prefix of v. In case
(2) v 6 u and u 6= v.
For example
ab  b, gallhager  gallier.

It is fairly tedious to prove that the lexicographic ordering is in fact a partial ordering.
In fact, it is a total ordering, which means that for any two strings u, v ∈ Σ∗ , either
u  v, or v  u.
The reversal w R of a string w is defined inductively as follows:

ǫR = ǫ,
(ua)R = auR ,

where a ∈ Σ and u ∈ Σ∗ .
For example
reillag = gallier R .

It can be shown that


(uv)R = v R uR .
Thus,
(u1 . . . un )R = uR R
n . . . u1 ,

and when ui ∈ Σ, we have


(u1 . . . un )R = un . . . u1 .

We can now define languages.

Definition 2.6. Given an alphabet Σ, a language over Σ (or simply a language) is any
subset L of Σ∗ .
2.1. ALPHABETS, STRINGS, LANGUAGES 13

If Σ 6= ∅, there are uncountably many languages.


A Quick Review of Finite, Infinite, Countable, and Uncountable Sets
For details and proofs, see Discrete Mathematics, by Gallier.
Let N = {0, 1, 2, . . .} be the set of natural numbers.
Recall that a set X is finite if there is some natural number n ∈ N and a bijection between
X and the set [n] = {1, 2, . . . , n}. (When n = 0, X = ∅, the empty set.)
The number n is uniquely determined. It is called the cardinality (or size) of X and is
denoted by |X|.
A set is infinite iff it is not finite.
Recall that any injection or surjection of a finite set to itself is in fact a bijection.
The above fails for infinite sets.
The pigeonhole principle asserts that there is no bijection between a finite set X and any
proper subset Y of X.
Consequence: If we think of X as a set of n pigeons and if there are only m < n boxes
(corresponding to the elements of Y ), then at least two of the pigeons must share the same
box.
As a consequence of the pigeonhole principle, a set X is infinite iff it is in bijection with
a proper subset of itself.
For example, we have a bijection n 7→ 2n between N and the set 2N of even natural
numbers, a proper subset of N, so N is infinite.
A set X is countable (or denumerable) if there is an injection from X into N.
If X is not the empty set, then X is countable iff there is a surjection from N onto X.
It can be shown that a set X is countable if either it is finite or if it is in bijection with
N.
We will see later that N×N is countable. As a consequence, the set Q of rational numbers
is countable.
A set is uncountable if it is not countable.
For example, R (the set of real numbers) is uncountable.
Similarly

(0, 1) = {x ∈ R | 0 < x < 1}

is uncountable. However, there is a bijection between (0, 1) and R (find one!)


The set 2N of all subsets of N is uncountable.
14 CHAPTER 2. BASICS OF FORMAL LANGUAGE THEORY

If Σ 6= ∅, then the set Σ∗ of all strings over Σ is infinite and countable.


Suppose |Σ| = k with Σ = {a1 , . . . , ak }.
If k = 1 write a = a1 , and then

{a}∗ = {ǫ, a, aa, aaa, . . . , an , . . .}.

We have the bijection n 7→ an from N to {a}∗ .


If k ≥ 2, then we can think of the string
u = ai1 · · · ain
as a representation of the integer ν(u) in base k shifted by (k n − 1)/(k − 1),

ν(u) = i1 k n−1 + i2 k n−2 + · · · + in−1 k + in


kn − 1
= + (i1 − 1)k n−1 + · · · + (in−1 − 1)k + in − 1.
k−1

(with ν(ǫ) = 0).


We leave it as an exercise to show that ν : Σ∗ → N is a bijection.
In fact, ν correspond to the enumeration of Σ∗ where u precedes v if |u| < |v|, and u
precedes v in the lexicographic ordering if |u| = |v|.
For example, if k = 2 and if we write Σ = {a, b}, then the enumeration begins with

ǫ, a, b, aa, ab, ba, bb.



On the other hand, if Σ 6= ∅, the set 2Σ of all subsets of Σ∗ (all languages) is uncountable.

Indeed, we can show that there is no surjection from N onto 2Σ .

First, we show that there is no surjection from Σ∗ onto 2Σ .

We claim that if there is no surjection from Σ∗ onto 2Σ , then there is no surjection from

N onto 2Σ either.

Assume by contradiction that there is a surjection g : N → 2Σ . But, if Σ 6= ∅, then Σ∗ is
infinite and countable, thus we have the bijection ν : Σ∗ → N. Then the composition
ν g ∗
Σ∗ / N / 2Σ
is a surjection, because the bijection ν is a surjection, g is a surjection, and the composition
of surjections is a surjection, contradicting the hypothesis that there is no surjection from

Σ∗ onto 2Σ .

To prove that that there is no surjection Σ∗ onto 2Σ . We use a diagonalization argument.
This is an instance of Cantor’s Theorem.
2.2. OPERATIONS ON LANGUAGES 15


Theorem 2.1. (Cantor) There is no surjection from Σ∗ onto 2Σ .

Proof. Assume there is a surjection h : Σ∗ → 2Σ , and consider the set

D = {u ∈ Σ∗ | u ∈
/ h(u)}.

By definition, for any u we have u ∈ D iff u ∈


/ h(u). Since h is surjective, there is some
w ∈ Σ∗ such that h(w) = D. Then, since by definition of D and since D = h(w), we have
w ∈ D iff w ∈
/ h(w) = D,
a contradiction. Therefore g is not surjective.

Therefore, if Σ 6= ∅, then 2Σ is uncountable.
We will try to single out countable “tractable” families of languages.
We will begin with the family of regular languages, and then proceed to the context-free
languages.
We now turn to operations on languages.

2.2 Operations on Languages


A way of building more complex languages from simpler ones is to combine them using
various operations. First, we review the set-theoretic operations of union, intersection, and
complementation.
Given some alphabet Σ, for any two languages L1 , L2 over Σ, the union L1 ∪ L2 of L1
and L2 is the language
L1 ∪ L2 = {w ∈ Σ∗ | w ∈ L1 or w ∈ L2 }.

The intersection L1 ∩ L2 of L1 and L2 is the language


L1 ∩ L2 = {w ∈ Σ∗ | w ∈ L1 and w ∈ L2 }.

The difference L1 − L2 of L1 and L2 is the language


L1 − L2 = {w ∈ Σ∗ | w ∈ L1 and w ∈
/ L2 }.
The difference is also called the relative complement.
A special case of the difference is obtained when L1 = Σ∗ , in which case we define the
complement L of a language L as

L = {w ∈ Σ∗ | w ∈
/ L}.

The above operations do not use the structure of strings. The following operations use
concatenation.
16 CHAPTER 2. BASICS OF FORMAL LANGUAGE THEORY

Definition 2.7. Given an alphabet Σ, for any two languages L1 , L2 over Σ, the concatenation
L1 L2 of L1 and L2 is the language

L1 L2 = {w ∈ Σ∗ | ∃u ∈ L1 , ∃v ∈ L2 , w = uv}.

For any language L, we define Ln as follows:

L0 = {ǫ},
Ln+1 = Ln L (n ≥ 0).

The following properties are easily verified:

L∅ = ∅,
∅L = ∅,
L{ǫ} = L,
{ǫ}L = L,
(L1 ∪ {ǫ})L2 = L1 L2 ∪ L2 ,
L1 (L2 ∪ {ǫ}) = L1 L2 ∪ L1 ,
Ln L = LLn .

In general, L1 L2 6= L2 L1 .
So far, the operations that we have introduced, except complementation (since L = Σ∗ −L
is infinite if L is finite and Σ is nonempty), preserve the finiteness of languages. This is not
the case for the next two operations.

Definition 2.8. Given an alphabet Σ, for any language L over Σ, the Kleene ∗-closure L∗
of L is the language
[
L∗ = Ln .
n≥0

The Kleene +-closure L+ of L is the language


[
L+ = Ln .
n≥1

Thus, L∗ is the infinite union

L∗ = L0 ∪ L1 ∪ L2 ∪ . . . ∪ Ln ∪ . . . ,
2.2. OPERATIONS ON LANGUAGES 17

and L+ is the infinite union

L+ = L1 ∪ L2 ∪ . . . ∪ Ln ∪ . . . .

Since L1 = L, both L∗ and L+ contain L.


In fact,

L+ = {w ∈ Σ∗ , ∃n ≥ 1,
∃u1 ∈ L · · · ∃un ∈ L, w = u1 · · · un },

and since L0 = {ǫ},

L∗ = {ǫ} ∪ {w ∈ Σ∗ , ∃n ≥ 1,
∃u1 ∈ L · · · ∃un ∈ L, w = u1 · · · un }.

Thus, the language L∗ always contains ǫ, and we have

L∗ = L+ ∪ {ǫ}.
However, if ǫ ∈ / L+ . The following is easily shown:
/ L, then ǫ ∈

∅∗ = {ǫ},
L+ = L∗ L,
L∗∗ = L∗ ,
L∗ L∗ = L∗ .

The Kleene closures have many other interesting properties.


Homomorphisms are also very useful.
Given two alphabets Σ, ∆, a homomorphism
h : Σ∗ → ∆∗ between Σ∗ and ∆∗ is a function
h : Σ∗ → ∆∗ such that

h(uv) = h(u)h(v) for all u, v ∈ Σ∗ .


Letting u = v = ǫ, we get

h(ǫ) = h(ǫ)h(ǫ),

which implies that (why?)


18 CHAPTER 2. BASICS OF FORMAL LANGUAGE THEORY

h(ǫ) = ǫ.

If Σ = {a1 , . . . , ak }, it is easily seen that h is completely determined by h(a1 ), . . . , h(ak )


(why?)
Example: Σ = {a, b, c}, ∆ = {0, 1}, and

h(a) = 01, h(b) = 011, h(c) = 0111.

For example

h(abbc) = 010110110111.

Given any language L1 ⊆ Σ∗ , we define the image h(L1 ) of L1 as

h(L1 ) = {h(u) ∈ ∆∗ | u ∈ L1 }.

Given any language L2 ⊆ ∆∗ , we define the


inverse image h−1 (L2 ) of L2 as

h−1 (L2 ) = {u ∈ Σ∗ | h(u) ∈ L2 }.

We now turn to the first formalism for defining languages, Deterministic Finite Automata
(DFA’s)
Chapter 3

DFA’s, NFA’s, Regular Languages

The family of regular languages is the simplest, yet interesting family of languages.
We give six definitions of the regular languages.

1. Using deterministic finite automata (DFAs).

2. Using nondeterministic finite automata (NFAs).

3. Using a closure definition involving, union, concatenation, and Kleene ∗.

4. Using regular expressions.

5. Using right-invariant equivalence relations of finite index (the Myhill-Nerode charac-


terization).

6. Using right-linear context-free grammars.

We prove the equivalence of these definitions, often by providing an algorithm for con-
verting one formulation into another.
We find that the introduction of NFA’s is motivated by the conversion of regular expres-
sions into DFA’s.
To finish this conversion, we also show that every NFA can be converted into a DFA
(using the subset construction).
So, although NFA’s often allow for more concise descriptions, they do not have more
expressive power than DFA’s.
NFA’s operate according to the paradigm: guess a successful path, and check it in poly-
nomial time.
This is the essence of an important class of hard problems known as N P, which will be
investigated later.

19
20 CHAPTER 3. DFA’S, NFA’S, REGULAR LANGUAGES

We will also discuss methods for proving that certain languages are not regular (Myhill-
Nerode, pumping lemma).
We present algorithms to convert a DFA to an equivalent one with a minimal number of
states.

3.1 Deterministic Finite Automata (DFA’s)


First we define what DFA’s are, and then we explain how they are used to accept or reject
strings. Roughly speaking, a DFA is a finite transition graph whose edges are labeled with
letters from an alphabet Σ.
The graph also satisfies certain properties that make it deterministic. Basically, this
means that given any string w, starting from any node, there is a unique path in the graph
“parsing” the string w.
Example 1. A DFA for the language

L1 = {ab}+ = {ab}∗ {ab},

i.e.,
L1 = {ab, abab, ababab, . . . , (ab)n , . . .}.

Input alphabet: Σ = {a, b}.


State set Q1 = {0, 1, 2, 3}.
Start state: 0.
Set of accepting states: F1 = {2}.
Transition table (function) δ1 :

a b
0 1 3
1 3 2
2 1 3
3 3 3

Note that state 3 is a trap state or dead state.


Here is a graph representation of the DFA specified by the transition function shown
above:
3.1. DETERMINISTIC FINITE AUTOMATA (DFA’S) 21
a b
0 1 2
a
a
b b
3
a, b

Figure 3.1: DFA for {ab}+

Example 2. A DFA for the language


L2 = {ab}∗ = L1 ∪ {ǫ}
i.e.,
L2 = {ǫ, ab, abab, ababab, . . . , (ab)n , . . .}.
Input alphabet: Σ = {a, b}.
State set Q2 = {0, 1, 2}.
Start state: 0.
Set of accepting states: F2 = {0}.
Transition table (function) δ2 :

a b
0 1 2
1 2 0
2 2 2
State 2 is a trap state or dead state.
Here is a graph representation of the DFA specified by the transition function shown
above:

a
0 1
b

b a
2
a, b

Figure 3.2: DFA for {ab}∗


22 CHAPTER 3. DFA’S, NFA’S, REGULAR LANGUAGES

Example 3. A DFA for the language

L3 = {a, b}∗ {abb}.

Note that L3 consists of all strings of a’s and b’s ending in abb.
Input alphabet: Σ = {a, b}.
State set Q3 = {0, 1, 2, 3}.
Start state: 0.
Set of accepting states: F3 = {3}.
Transition table (function) δ3 :

a b
0 1 0
1 1 2
2 1 3
3 1 0

Here is a graph representation of the DFA specified by the transition function shown
above:

b
b a
a b b
0 1 2 3
a

Figure 3.3: DFA for {a, b}∗ {abb}

Is this a minimal DFA?

Definition 3.1. A deterministic finite automaton (or DFA) is a quintuple


D = (Q, Σ, δ, q0 , F ), where

• Σ is a finite input alphabet;

• Q is a finite set of states;


3.1. DETERMINISTIC FINITE AUTOMATA (DFA’S) 23

• F is a subset of Q of final (or accepting) states;


• q0 ∈ Q is the start state (or initial state);
• δ is the transition function, a function

δ : Q × Σ → Q.

For any state p ∈ Q and any input a ∈ Σ, the state q = δ(p, a) is uniquely determined.
Thus, it is possible to define the state reached from a given state p ∈ Q on input w ∈ Σ∗ ,
following the path specified by w.
Technically, this is done by defining the extended transition function δ ∗ : Q × Σ∗ → Q.
Definition 3.2. Given a DFA D = (Q, Σ, δ, q0 , F ), the extended transition function δ ∗ : Q ×
Σ∗ → Q is defined as follows:

δ ∗ (p, ǫ) = p,
δ ∗ (p, ua) = δ(δ ∗ (p, u), a),

where a ∈ Σ and u ∈ Σ∗ .

It is immediate that δ ∗ (p, a) = δ(p, a) for a ∈ Σ.


The meaning of δ ∗ (p, w) is that it is the state reached from state p following the path
from p specified by w.
We can show (by induction on the length of v) that

δ ∗ (p, uv) = δ ∗ (δ ∗ (p, u), v) for all p ∈ Q and all u, v ∈ Σ∗

For the induction step, for u ∈ Σ∗ , and all v = ya with y ∈ Σ∗ and a ∈ Σ,

δ ∗ (p, uya) = δ(δ ∗ (p, uy), a) by definition of δ ∗


= δ(δ ∗ (δ ∗ (p, u), y), a) by induction
= δ ∗ (δ ∗ (p, u), ya) by definition of δ ∗ .

We can now define how a DFA accepts or rejects a string.


Definition 3.3. Given a DFA D = (Q, Σ, δ, q0 , F ), the language L(D) accepted (or recog-
nized) by D is the language

L(D) = {w ∈ Σ∗ | δ ∗ (q0 , w) ∈ F }.
24 CHAPTER 3. DFA’S, NFA’S, REGULAR LANGUAGES

Thus, a string w ∈ Σ∗ is accepted iff the path from q0 on input w ends in a final state.
The definition of a DFA does not prevent the possibility that a DFA may have states
that are not reachable from the start state q0 , which means that there is no path from q0 to
such states.
For example, in the DFA D1 defined by the transition table below and the set of final
states F = {1, 2, 3}, the states in the set {0, 1} are reachable from the start state 0, but
the states in the set {2, 3, 4} are not (even though there are transitions from 2, 3, 4 to 0, but
they go in the wrong direction).

a b
0 1 0
1 0 1
2 3 0
3 4 0
4 2 0

Since there is no path from the start state 0 to any of the states in {2, 3, 4}, the states
2, 3, 4 are useless as far as acceptance of strings, so they should be deleted as well as the
transitions from them.
Given a DFA D = (Q, Σ, δ, q0 , F ), the above suggests defining the set Qr of reachable (or
accessible) states as

Qr = {p ∈ Q | (∃u ∈ Σ∗ )(p = δ ∗ (q0 , u))}.

The set Qr consists of those states p ∈ Q such that there is some path from q0 to p (along
some string u).
Computing the set Qr is a reachability problem in a directed graph. There are various
algorithms to solve this problem, including breadth-first search or depth-first search.
Once the set Qr has been computed, we can clean up the DFA D by deleting all redundant
states in Q − Qr and all transitions from these states.
More precisely, we form the DFA Dr = (Qr , Σ, δr , q0 , Qr ∩ F ), where δr : Qr × Σ → Qr is
the restriction of δ : Q × Σ → Q to Qr .
If D1 is the DFA of the previous example, then the DFA (D1 )r is obtained by deleting
the states 2, 3, 4:

a b
0 1 0
1 0 1

It can be shown that L(Dr ) = L(D) (see the homework problems).


3.2. THE “CROSS-PRODUCT” CONSTRUCTION 25

A DFA D such that Q = Qr is said to be trim (or reduced).


Observe that the DFA Dr is trim. A minimal DFA must be trim.
Computing Qr gives us a method to test whether a DFA D accepts a nonempty language.
Indeed

L(D) 6= ∅ iff Qr ∩ F 6= ∅

We now come to the first of several equivalent definitions of the regular languages.
Regular Languages, Version 1

Definition 3.4. A language L is a regular language if it is accepted by some DFA.

Note that a regular language may be accepted by many different DFAs. Later on, we
will investigate how to find minimal DFA’s.
For a given regular language L, a minimal DFA for L is a DFA with the smallest number of
states among all DFA’s accepting L. A minimal DFA for L must exist since every nonempty
subset of natural numbers has a smallest element.
In order to understand how complex the regular languages are, we will investigate the
closure properties of the regular languages under union, intersection, complementation, con-
catenation, and Kleene ∗.
It turns out that the family of regular languages is closed under all these operations. For
union, intersection, and complementation, we can use the cross-product construction which
preserves determinism.
However, for concatenation and Kleene ∗, there does not appear to be any method
involving DFA’s only. The way to do it is to introduce nondeterministic finite automata
(NFA’s), which we do a little later.

3.2 The “Cross-product” Construction


Let Σ = {a1 , . . . , am } be an alphabet.
Given any two DFA’s D1 = (Q1 , Σ, δ1 , q0,1 , F1 ) and
D2 = (Q2 , Σ, δ2 , q0,2 , F2 ), there is a very useful construction for showing that the union, the
intersection, or the relative complement of regular languages, is a regular language.
Given any two languages L1 , L2 over Σ, recall that

L1 ∪ L2 = {w ∈ Σ∗ | w ∈ L1 or w ∈ L2 },
L1 ∩ L2 = {w ∈ Σ∗ | w ∈ L1 and w ∈ L2 },
L1 − L2 = {w ∈ Σ∗ | w ∈ L1 and w ∈/ L2 }.
26 CHAPTER 3. DFA’S, NFA’S, REGULAR LANGUAGES

Let us first explain how to constuct a DFA accepting the intersection L1 ∩ L2 . Let D1
and D2 be DFA’s such that L1 = L(D1 ) and L2 = L(D2 ).
The idea is to construct a DFA simulating D1 and D2 in parallel. This can be done by
using states which are pairs (p1 , p2 ) ∈ Q1 × Q2 .
Thus, we define the DFA D as follows:

D = (Q1 × Q2 , Σ, δ, (q0,1 , q0,2 ), F1 × F2 ),

where the transition function δ : (Q1 × Q2 ) × Σ → Q1 × Q2 is defined as follows:

δ((p1 , p2 ), a) = (δ1 (p1 , a), δ2 (p2 , a)),

for all p1 ∈ Q1 , p2 ∈ Q2 , and a ∈ Σ.


Clearly, D is a DFA, since D1 and D2 are. Also, by the definition of δ, we have

δ ∗ ((p1 , p2 ), w) = (δ1∗ (p1 , w), δ2∗ (p2 , w)),

for all p1 ∈ Q1 , p2 ∈ Q2 , and w ∈ Σ∗ .


Now, we have w ∈ L(D1 ) ∩ L(D2 )

iff w ∈ L(D1 ) and w ∈ L(D2 ),


iff δ1∗ (q0,1 , w) ∈ F1 and δ2∗ (q0,2 , w) ∈ F2 ,
iff (δ1∗ (q0,1 , w), δ2∗(q0,2 , w)) ∈ F1 × F2 ,
iff δ ∗ ((q0,1 , q0,2 ), w) ∈ F1 × F2 ,
iff w ∈ L(D).

Thus, L(D) = L(D1 ) ∩ L(D2 ).


We can now modify D very easily to accept L(D1 ) ∪ L(D2 ).
We change the set of final states so that it becomes (F1 × Q2 ) ∪ (Q1 × F2 ).
Indeed, w ∈ L(D1 ) ∪ L(D2 )

iff w ∈ L(D1 ) or w ∈ L(D2 ),


iff δ1∗ (q0,1 , w) ∈ F1 or δ2∗ (q0,2 , w) ∈ F2 ,
iff (δ1∗ (q0,1 , w), δ2∗(q0,2 , w)) ∈ (F1 × Q2 ) ∪ (Q1 × F2 ),
iff δ ∗ ((q0,1 , q0,2 ), w) ∈ (F1 × Q2 ) ∪ (Q1 × F2 ),
iff w ∈ L(D).

Thus, L(D) = L(D1 ) ∪ L(D2 ).


We can also modify D very easily to accept L(D1 ) − L(D2 ).
3.3. NONDETETERMINISTIC FINITE AUTOMATA (NFA’S) 27

We change the set of final states so that it becomes F1 × (Q2 − F2 ).


Indeed, w ∈ L(D1 ) − L(D2 )
iff w ∈ L(D1 ) and w ∈ / L(D2 ),
iff δ1 (q0,1 , w) ∈ F1 and δ2∗ (q0,2 , w) ∈

/ F2 ,
∗ ∗
iff (δ1 (q0,1 , w), δ2 (q0,2 , w)) ∈ F1 × (Q2 − F2 ),
iff δ ∗ ((q0,1 , q0,2 ), w) ∈ F1 × (Q2 − F2 ),
iff w ∈ L(D).
Thus, L(D) = L(D1 ) − L(D2 ).
In all cases, if D1 has n1 states and D2 has n2 states, the DFA D has n1 n2 states.

3.3 Nondeteterministic Finite Automata (NFA’s)


NFA’s are obtained from DFA’s by allowing multiple transitions from a given state on a
given input. This can be done by defining δ(p, a) as a subset of Q rather than a single state.
It will also be convenient to allow transitions on input ǫ.
We let 2Q denote the set of all subsets of Q, including the empty set. The set 2Q is the
power set of Q.
Example 4. A NFA for the language
L3 = {a, b}∗ {abb}.
Input alphabet: Σ = {a, b}.
State set Q4 = {0, 1, 2, 3}.
Start state: 0.
Set of accepting states: F4 = {3}.
Transition table δ4 :

a b
0 {0, 1} {0}
1 ∅ {2}
2 ∅ {3}
3 ∅ ∅

a, b
a b b
0 1 2 3

Figure 3.4: NFA for {a, b}∗ {abb}


28 CHAPTER 3. DFA’S, NFA’S, REGULAR LANGUAGES

Example 5. Let Σ = {a1 , . . . , an }, let


Lin = {w ∈ Σ∗ | w contains an odd number of ai ’s},
and let
Ln = L1n ∪ L2n ∪ · · · ∪ Lnn .

The language Ln consists of those strings in Σ∗ that contain an odd number of some
letter ai ∈ Σ.
Equivalently Σ∗ − Ln consists of those strings in Σ∗ with an even number of every letter
ai ∈ Σ.
It can be shown that every DFA accepting Ln has at least 2n states.
However, there is an NFA with 2n + 1 states accepting Ln .
We define NFA’s as follows.
Definition 3.5. A nondeterministic finite automaton (or NFA) is a quintuple
N = (Q, Σ, δ, q0 , F ), where
• Σ is a finite input alphabet;
• Q is a finite set of states;
• F is a subset of Q of final (or accepting) states;
• q0 ∈ Q is the start state (or initial state);
• δ is the transition function, a function
δ : Q × (Σ ∪ {ǫ}) → 2Q .

For any state p ∈ Q and any input a ∈ Σ ∪ {ǫ}, the set of states δ(p, a) is uniquely
determined. We write q ∈ δ(p, a).
Given an NFA N = (Q, Σ, δ, q0 , F ), we would like to define the language accepted by N.
However, given an NFA N, unlike the situation for DFA’s, given a state p ∈ Q and some
input w ∈ Σ∗ , in general there is no unique path from p on input w, but instead a tree of
computation paths.
For example, given the NFA shown below,

a, b
a b b
0 1 2 3

Figure 3.5: NFA for {a, b}∗ {abb}


3.3. NONDETETERMINISTIC FINITE AUTOMATA (NFA’S) 29

from state 0 on input w = ababb we obtain the following tree of computation paths:

0
a a

0 1
b
b
0 2
a a

0 1
b b
0 2
b b
0 3

Figure 3.6: A tree of computation paths on input ababb

Observe that there are three kinds of computation paths:

1. A path on input w ending in a rejecting state (for example, the lefmost path).

2. A path on some proper prefix of w, along which the computation gets stuck (for
example, the rightmost path).

3. A path on input w ending in an accepting state (such as the path ending in state 3).

The acceptance criterion for NFA is very lenient: a string w is accepted iff the tree of
computation paths contains some accepting path (of type (3)).
Thus, all failed paths of type (1) and (2) are ignored. Furthermore, there is no charge
for failed paths.
A string w is rejected iff all computation paths are failed paths of type (1) or (2).
The “philosophy” of nondeterminism is that an NFA
“guesses” an accepting path and then checks it in polynomial time by following this path.
We are only charged for one accepting path (even if there are several accepting paths).
A way to capture this acceptance policy if to extend the transition function δ : Q × (Σ ∪
{ǫ}) → 2Q to a function
Another Random Scribd Document
with Unrelated Content
The Project Gutenberg eBook of A history of the
Brazil
This ebook is for the use of anyone anywhere in the United
States and most other parts of the world at no cost and with
almost no restrictions whatsoever. You may copy it, give it away
or re-use it under the terms of the Project Gutenberg License
included with this ebook or online at www.gutenberg.org. If you
are not located in the United States, you will have to check the
laws of the country where you are located before using this
eBook.

Title: A history of the Brazil


comprising its geography, commerce, colonization,
aboriginal inhabitants, &c. &c. &c.

Author: James Henderson

Engraver: C. Shoosmith

Release date: January 24, 2024 [eBook #72778]

Language: English

Original publication: London: Longman Hurst Rees Orme and


Brown, 1821

Credits: Karin Spence and the Online Distributed Proofreading


Team at https://www.pgdp.net (This file was produced
from images generously made available by The
Internet Archive/American Libraries.)

*** START OF THE PROJECT GUTENBERG EBOOK A HISTORY


OF THE BRAZIL ***
On Stone by C. Shoosmith from a Sketch by Jas. Henderson.
Printed by Rowney & Forster.
DON JOHN VI. KING OF PORTUGAL & BRAZIL, & HIS ATTENDANTS AT RIO
DE JANEIRO.

HISTORY
OF

THE BRAZIL;
COMPRISING ITS
GEOGRAPHY, COMMERCE, COLONIZATION,
ABORIGINAL INHABITANTS,
&c. &c. &c.

By JAMES HENDERSON,
RECENTLY FROM SOUTH AMERICA.

ILLUSTRATED WITH TWENTY-EIGHT PLATES AND TWO MAPS.

LONDON:
PRINTED FOR THE AUTHOR,
AND PUBLISHED BY LONGMAN, HURST, REES, ORME, AND BROWN,
PATERNOSTER-ROW.

1821.
MARCHANT, Printer, Ingram-Court,
Fenchurch-Street, London.
TO THE

RIGHT HONOURABLE

THE LORD VISCOUNT LOWTHER.

My Lord,
Were the writer of the following Work a well-known and admired
member of the Literary Community he would still be fortunate in the
permission of having it dedicated to your Lordship, as your
Lordship’s literary, scientific, and commercial knowledge, correct
judgement, and amiable qualities, more than the influence of
elevated birth and rank, would confer upon it increased
recommendation. But coming forward as I do, an unknown
contributor to the stock of general knowledge, I am peculiarly happy
in having so high a passport to the notice of the Public, in a Work
which professes to communicate new information respecting a
portion of South America, now more than ever interesting to the
commercial, political, and scientific worlds. Whatever faults it
possesses, the pains I have taken to obtain authentic information
will, I trust, render it not unworthy of their and your Lordship’s notice.
If the style in which I present the new fruit, gathered from the
branches of the tree of knowledge that are spread in a far country, is
not considered interesting, the fruit itself will be found, I hope,
acceptable and useful.
I have the honour to subscribe myself,
My Lord,
Your Lordship’s most faithful and devoted Servant,
JAMES HENDERSON.
London, August 1, 1821.
NOTICE TO THE READER.

The object of this Work is to describe the state of the Brazil, from
its first discovery down to the present time;—to trace distinctly the
boundaries of the twenty-two provinces which it comprises, their sub-
divisions into comarcas or districts, and their rivers; to enumerate the
povoaçoes or establishments in each province, consisting of cities,
towns, (and the dates they were so erected by his present Majesty,
or previously,) freguezias, (parishes,) arraials, aldeias, (villages,)
presidios, (garrisons,) hermitages, &c. with the nature of their
agricultural productions, the composition of their inhabitants, whether
whites, mulattos, mamalucos, mesticos, Christianized Indians, or
Africans.
The numerous tribes of savage Indians, still existing in this region
are also described; with the mountains, minerals, and leading
objects in the animal and vegetable worlds. The state of the
government, revenue, society, and minor subjects are investigated,
and more particularly the present commercial relations between
Great Britain and the Brazil. The friendly assistance I experienced
from many persons in South America, as well as from some
governors and ex-governors of provinces, has furnished a portion of
the authentic materials of the Work.
My first intention in undertaking it was to have adhered to a
geographical and commercial account of the country, but as the
recent publication of Padre Manoel Ayres de Cazal, (in producing
which he had been many years engaged,) furnishing me, not only
with copious information upon the first subject, but also upon its
history, civil and natural, I conceived that it would not be
unacceptable to the British reader to give an abridged account of
each province, from their first colonization, combined with their
geography, productions, commerce, &c.
Upon the history of this country, however, the work of Mr.
Southey is complete, and does as much honour to the talent of that
gentleman as to his unwearied research. The labour, even with all
his facilities, which such an undertaking must have required, cannot
but have been very considerable.
Padre Cazal, who is a man of some talent, enjoyed decided
advantages, it will be allowed, from his ecclesiastical situation, in
arriving at full and authentic intelligence, as to the present condition
of the towns, productions, &c. derived from Government documents,
his own personal research, the diaries of Certanistas, (persons
traversing the interior,) and from numerous individuals, who might
not have been disposed to grant the same privileges to any one
differently circumstanced. In the many instances wherein I have had
opportunities of putting the veracity of his statements to the test I
have found them correct and impartial. No doubt can fairly exist as to
the perfect authenticity of the whole, additionally confirmed as it is,
by Mr. Southey’s having had recourse to the same authority in the
latter part of his third volume.
The general reader may not be peculiarly interested with that
portion of this publication which details the towns and their
productions, and in which monotony is unavoidable, although they
will be valuable as references for the merchant and many others, as,
with the evidently growing commerce of this fine country, already
taking off annually three million of British manufactures, each of
those places will progressively become more and more important.
The plates, which are amongst the best in their style, are
executed, by an able artist, upon stone, from sketches taken on the
spot; and the map is formed by myself from the materials of the
Work. The Appendix is explanatory of the objects in Zoology and
Phytology, which would not have been generally understood by their
native designations; and I must here apologize to the reader for not
presenting them in scientific nomenclature.
CONTENTS.

CHAPTER I.
Page
Voyage from England to Rio de Janeiro 1

CHAP. II.
From the first discovery down to the arrival of the Royal Family there, and
its present division into provinces—The general character of the Indians 12

CHAP. III.
PROVINCE OF RIO DE JANEIRO.
Its colonization—contests with, the French and Tamoyo Indians—
expulsion of the French—foundation of St. Sebastian—boundaries—
division into comarcas—mountains—principal rivers—lakes—bays—
capes—islands—mineralogy—zoology—phytology—cities and towns—
boundaries, towns, and productions of the comarcas of Ilha Grande and
Parahiba Nova—boundaries of the comarca of Rio de Janeiro—the
metropolis—situation—English burial-ground—streets—royal mode of
riding—compulsory homage upon the occasion—churches—convents—
Gloria Hill—female convents—visit to one—fountains—visit to the
aqueduct—squares—palace—public buildings—public garden—library
—manufactories—theatre—roads leading from the city—palace of St.
Christovao—troops of miners and others from the interior—Gaza de
Don Pedro—royal mill, shacara, and stables—fire-works—Beija Mao—
fidalgos and higher orders of society—splendour of churches—royal
chapel—religious festivals and observances—funeral processions—
catacombs—the host—state of society—markets 31

CHAP. IV.
PROVINCE OF RIO DE JANEIRO—continued.
Population of the capital—negroes—nocturnal clamour of reptiles— 72
vampire hat—state of literature—jealousy—dead bodies—military—
bank—revenue—imposts—diamonds—visit to Campinha—tenure of
lands—proof of fertility—Swiss emigrants—visit to the cascades of
Tejuca—commerce—judicial procedure—pauta and convention—new
exchange—foundation of English church—towns, villages, and
productions of the comarca of Rio de Janeiro—boundaries, productions,
rivers, lakes, and povoaçoes of the comarca of Cape Frio—boundaries,
Indians, rivers, lakes, towns, and sugar-works of the comarca of
Goytacazes—boundaries, Coroado Indians, and povoaçoes of the
comarca of Canta Gallo

CHAP. V.
PROVINCE OF RIO GRANDE DO SUL.
Colonization—boundaries—climate—aspect and productions—contests
between Spaniards and Portuguese—divisionary line between these
two powers—opposition by the Indians of the seven missions—their
defeat—revived contests between Spaniards and Portuguese—
mountains—rivers—lakes—capes and ports—islands—mineralogy—
phytology—zoology—large fazendas for breeding cattle—mode of
management—sheep-flocks—use of the laço and balls—towns, nature
of exports, villages, &c. including those of the district of Monte Video 110

CHAP. VI.
PROVINCE OF PARANNA.
Boundaries—climate—productions—Matte the most lucrative—first
discoverers—proceedings of the Spanish Jesuits—Guarani Indians
formed into reduções, or villages—nature of those missions—expulsion
of the Jesuits—delivery of the missions to other ecclesiastics—their
decay—mountains—mineralogy—rivers and lakes—phytology—zoology
—towns, parishes, &c.—remaining establishments of the Jesuitical
missions 134

CHAP. VII.
PROVINCE OF URUGUAY.
Foundation of aldeias, called missions, by the Spanish Jesuits for the
Tappe Indians—flourish till the expulsion of that sect—subsequent
decay—war between the Spaniards and Portuguese—conquest of the
seven missions by the latter power in 1801—governor sent—boundaries
—mountains—rivers—phytology—zoology—names and population of
the seven missions at their conquest 145

CHAP. VIII.
PROVINCE OF ST. CATHARINA.
Boundaries—colonization—productions—mountains—mineralogy—
phytology—zoology—rivers, lakes, and ports—towns, parishes, &c.—
agricultural establishments—population—islands—delightful climate 151
CHAP. IX.
PROVINCE OF ST. PAULO.
Boundaries—first settlement—mountains—mineralogy—rivers and ports—
islands—phytology—zoology—Bugre Indians, dwellings and customs—
character of the Paulistas—division into comarcas—comarca of
Curytiba—towns and productions—comarcas of St. Paulo and Hitu—
towns and productions 162

CHAP. X.
PROVINCE OF MATTO GROSSO.
First explorers—gold discovered—two brothers appointed for the purpose
of exacting the fifths on gold—their atrocious conduct—people attracted
here by the fame of gold—destruction of a party by the Indians—
Payagoa and Guaycuru Nations discovered—their alliance—their fatal
attacks upon the Portuguese—their disunion—continued hostilities of
the Guaycurus—conflicts with them—attempts to make peace with the
Indians—treachery of the Guaycurus—severe drought—arrival of a
governor—promotes the navigation to Para—extent and boundaries—
division into districts.—District of Camapuania—mineralogy—phytology
—rivers—zoology—various Indian tribes—povoaçoes.—District of Matto
Grosso—mountains—mineralogy—phytology—zoology—rivers—
capital.—District of Cuiaba—mineralogy—phytology—zoology—rivers—
povoaçoes—Indians.—District of Bororonia—Indians—rivers—lakes.—
District of Juruenna—Indians—rivers—forts.—District of Arinos—Indians
—rivers.—District of Tappiraquia—Indians—rivers.—Lands of these
districts fertile and auriferous 189

CHAP. XI.
PROVINCE OF GOYAZ.
First discovery of gold—attempts of Bueno to find the Goya Territory—
settlements —boundaries—extent—mineralogy—zoology—phytology—
cattle and gold its exports—principal rivers—comarcas—Julgados.—
District of Cayaponia—limits—Indians—rivers.—District of Goyaz—
limits—mountains—capital—povoaçoes.—District of Nova Beira—limits
—Indians—rivers—povoaçoes—Indians reduced to peace—aldeias
established for them.—District of Tucantines—limits—rivers—Indians—
povoaçoes.—District of Parannan—limits—rivers—povoaçoes.—District
of Rio das Velhas—limits—rivers—Indians—povoaçoes 231

CHAP. XII.
PROVINCE OF MINAS GERAES.
Boundaries—extent—climate—discoverers of its mines—mountains—
rivers—mineralogy—zoology—phytology—exports—comarcas and
towns.—Comarca of Villa Rica—limits—mountains—rivers—capital—
povoaçoes.—Comarca of Rio das Mortes—limits—mountains—rivers—
povoaçoes.—Comarca of Sabara—limits—mountains—rivers—lakes—
povoaçoes.—Comarca of Serro Frio—limits—rich in diamonds—
mountains—rivers—povoaçoes.—Diamond district—Tijuco—seat of
diamond junta 258

CHAP. XIII.
PROVINCE OF ESPIRITO SANTO.
Extent—boundaries—misfortunes of its donatories—spirited resistance of
the Indians—partial cultivation—principally possessed by Indians—
mountains—mineralogy—zoology—descents of Indians to the coast—
phytology—rivers and ports—povoaçoes.—Island of Ascension 288

CHAP. XIV.
PROVINCE OF PORTO SEGURO.
Boundaries—prosperity of its first donatory—reversion to the crown in a
bad state—present partial cultivation—Indians—mountains—mineralogy
—zoology—phytology—rivers, lakes, and ports—povoaçoes—abrolhos 297

CHAP. XV.
PROVINCE OF BAHIA.
Boundaries—Caramuru—first donatory—cruel war of the Indians—the
capitania forsaken—return of the donatory—shipwreck—slaughter of all
but Caramuru—governor-general—foundation of St. Salvador.—
Comarca of the Ilheos—originally a capitania—extent—fertility—
mountains—mineralogy—phytology—zoology—rivers and lakes—
povoaçoes.—Comarca of Jacobina—extent—mineralogy—mountains—
rivers—phytology—zoology—povoaçoes.—Comarca of Bahia—extent—
mountains—mineralogy—phytology—zoology—islands—rivers—
povoaçoes.—St. Salvador—churches and convents—public buildings—
Sepulchre of Caramuru’s wife—negroes—commerce—produce—
exports in 1817 and 1818—state of society—adoption of a new
constitution 309

CHAP. XVI.
PROVINCE OF SEREGIPE D’EL REY.
Colonization—reduction of the Indians—extent—mountains rivers and 347
lakes—mineralogy—zoology—phytology—povoaçoes

CHAP. XVII.
PROVINCE OF PERNAMBUCO.
Voyage from Rio de Janeiro—first donatories—taken by the Dutch—
restoration—reversion to the crown—Indians—boundaries—mountains
—colony of negroes—mineralogy—zoology—phytology—rivers—
islands—comarcas of Ollinda, Recife, Alagoas—povoaçoes—ouvidoria
of the certain of Pernambuco—rivers—towns—Recife, or Pernambuco
—Ollinda—Mattutos—state of society—apathy—environs—revolution in
1817—military government—adoption of a new constitution—holidays—
produce—inspection—sugar engenho—contribution-fund—population—
Fribourg House 355

CHAP. XVIII.
PROVINCE OF PARAHIBA.
Extent—capitania of Itamaraca—slow advancement—taken by the Dutch
—restoration—capes and ports—rivers—mountains—zoology—
phytology—povoaçoes—capital—British establishments—produce 394

CHAP. XIX.
PROVINCE OF RIO GRANDE DO NORTE.
Contests with Indians—conquest—taken by the Dutch—restored—extent
—sterility of soil—capes and ports—mineralogy—mountains—zoology
—phytology—rivers and lakes—povoaçoes—island of Fernando de
Noronha 404

CHAP. XX.
PROVINCE OF SIARA.
Colonization—boundaries—Indians—taken by the Dutch—restored —
mountains—mineralogy—zoology—phytology—rivers and lakes—
povoaçoes 412

CHAP. XXI.
PROVINCE OF PIAUHY.
Boundaries—first settlers—cattle fazendas—mountains—mineralogy—
rivers—towns 424

CHAP. XXII.
PROVINCE OF MARANHAM.
First donatory—shipwreck of persons intended for its colonization— 433
establishment of the French—retaken—foundation of capital—taken by
the Dutch—retaken—agricultural company—boundaries—rivers, ports,
and islands—mineralogy—phytology—zoology—Indians—povoaçoes—
city of Maranham—commerce—exports of produce

CHAP. XXIII.
PROVINCE OF PARA.
First settlement—contests with Indians—slavery of the Indians—their
liberation—Boundaries—mineralogy—phytology—zoology—ports and
rivers—Igaruana Indians.—District of Para-Proper—capital—buildings—
exports—English establishments—adoption of a new constitution—
towns.—District of Xingutania—limits—in possession of Indians—rivers
—towns.—District of Tapajonia—limits—rivers—Indians—towns.—
District of Mundrucania—rivers—principally possessed by the Indians—
their different customs—towns 448

CHAP. XXIV.
PROVINCE OF SOLIMOES.
Jurisdiction—origin of its name—boundaries and extent—partially known
—division into six districts—rivers—various Indians—customs—
povoaçoes 477

CHAP. XXV.
PROVINCE OF GUIANNA.
Boundaries—islands—rivers—towns—Indians 485

CHAP. XXVI.
Conclusive observations 498

Appendix 501
LIST OF SUBSCRIBERS.
A
Abbey, Richard, esq. Pancras-lane.
Ablet, Isaac, esq. Bucklersbury.
Ainslie, Dr. Dover-street.
Ainsworth, Thos. esq. solicitor, Manchester.
Allen, John, esq. Manchester.
Anderson, John, esq. St. Vincent’s Street, Glasgow.
Andrew, Jonathan, esq. Manchester.
Andrew, Thomas, esq. jun. Manchester.
Andrew, George, esq. Green-hill, Cheshire.
Andrew, Robert, esq. Green-Mount, Manchester.
Ansley, Alderman, 95, Park-street.
Ashton, John, esq. New Cannon-street, Manchester.
Ashton, Thomas, esq. Liverpool.
Atkinson, William, esq. Nicholas-lane.
Atkinson, Matthew, esq. Temple-Sowerby.
Austwick, ——, esq. Friday-street.

B
Becket, The Right Hon. John, Judge-Advocate, M.P. Downing-street.
Bamber, W. and Co. Messrs. Manchester.
Barnett, John, esq. City-road.
Barrow, Thomas, esq. Manchester.
Barton, Sir William, Henry-st. Liverpool.
Bateman, James, esq. Islington-house, Manchester.
Beardsworth, George, esq. High-street, Manchester.
Beck, Francis, esq. 12, Old Jewry.
Benkhausen, George, esq. Russian Vice-Consul, Winchester-street.
Bentham, William, esq. Gower-street.
Bentley, John, jun. esq. Stockport.
Bibby, John, esq. Liverpool.
Bielby, Hyde, and Co. Messrs. Birmingham.
Birkbeck, George, esq. M.P. Cateaton-st.
Birtless, Thomas, esq. Manchester.
Blackett, J. jun. esq. 20, London-street.
Blaikie, Robert, esq. 4, St. Hanover-street, Glasgow.
Blair, George, esq. Bolton.
Blanckenhagen, J. C. esq. King-street.
Bolling, Edward, jun. esq. Bolton.
Bolton, J. esq. Liverpool.
Bond, J. esq. Church-street, Stoke Newington.
Bone, Mrs. 10, Cambridge-row, Hackney.
Booth, Benjamin, esq. Manchester.
Booth, Thomas, esq. Liverpool.
Boothby, J. B. esq. Everton, near Liverpool.
Bonsor, Joseph, esq. Salisbury-square.
Bousfield, John, esq. Manchester.
Bowen, Charles, esq. Chandos-st. Cavendish-square.
Bradshaw, John, esq. Manchester.
Bradley, Thomas, esq. Mark-lane.
Bradock, J. esq. St. James’s Square, Manchester.
Brandt, Charles, esq. Manchester.
Broadbent, James, esq. Manchester.
Brocklebank, Thomas, esq. Liverpool.
Brotherston, J. esq. Liverpool.
Broughton, ——, esq. Mecklenburg-square.
Brown, Archibald, esq. Glasgow.
Brown, James, esq. 190, Cross, Glasgow.
Brown, S. esq. Liverpool.
Brown, James, esq. St. Mildred’s Court.
Brown, Robert, esq. 157, Cheapside.
Buchan, Lawrence, esq. Manchester.
Buchannan, John, esq. Liverpool.
Buckle, John William, esq. Mark-lane.
Burgess, Henry, esq. Manchester.
Brunton, Thomas, esq. Commercial-road.
Burra, Robert, esq. Watling-street.
Bury, James, esq. Lever-street, Manchester.
Butler, W. H. esq. Water-lane.

C
Campbell, Thomas, esq. 23, Old Burlington-street.
Campbell, Charles, esq. Bishopsgate-street.
Campbell, J. esq. Liverpool.
Cardale, W. esq. Bedford-row.
Carmalt, C. esq. 30, Bow-lane.
Capper, Thomas, esq. Beaufort-buildings, Strand.
Carrick, Robert, esq. banker, Glasgow.
Carruthers, John, esq. Leadenhall-street.
Case, John Ashton, esq. Liverpool.
Chance, W. and G. Messrs. Birmingham.
Chetwode, C. esq. Liverpool.
Christian, Professor, Gray’s Inn.
Christie, John and Robert, and Co. Messrs. Manchester.
Clark, John, esq. Crutched Friars.
Clarkson, Thomas, esq. Playford-hall, near Ipswich.
Coats, Edward, esq. 35, Bernard-street, Russell-square.
Cockshott, James, esq. Pernambuco.
Cohn, G. J. and Sons, Messrs. Manchester.
Collier, Josiah, esq. Manchester.
Collins, Edward, esq. Bell-street, Glasgow.
Collinson, Thomas, esq. Lombard-street.
Collinson, John, esq. 29, Lambeth Marsh.
Colquhoun, Archibald, esq. Turner’s Court, Glasgow.
Cook, James, esq. 40, Mincing-lane.
Cooke, Isaac, esq. Liverpool.
Cooper, John and F. Messrs. Old ’Change.
Cooper, T. W. esq. Harleyford-place, Kennington.
Cooper, Astley, esq. New-street, Spring-Gardens.
Copland, Robert, esq. Liverpool.
Copling, John, esq. Newgate-street.
Corbould, Charles, esq. 4, Carey-lane, Foster-lane.
Cotter, Lieutenant-Colonel, Pernambuco.
Courtney, Thomas, esq. Old Jewry.
Cowie, George, esq. Russell-square.
Crammond, A. L. esq. 11, Leadenhall-st.
Crole, D. esq. Old Broad-street.
Crosby, Rev. Robert, A. M. Hoxton-sq.
Croggon, William, esq. 64, Cornhill.

D
De Dubatchefsky, A. esq. Russian Consul-General, 28, Great Winchester-st.
Da Costa, A. J. esq. Portuguese Consul, Liverpool.
Dalgairns, P. esq. 5, Martin’s Lane.
Dalglish, Robert, esq. Glasgow.
Darch, Thomas, esq. Admiralty.
Davenport, James, and Co. Messrs. 82, Fleet-street.
Davison, John, esq. 37, Gutter-lane.
Dawson, Jonathan, esq. Stratford, Essex.
Dawes, John, esq. Threadneedle-street.
Dawson, Jonathan, esq. Manchester.
Dawson, Richard, esq. Liverpool.
De la Chaumette, L. J. esq. Angel-court.
Delisle, Z. esq. Church-st. Stoke Newington.
Delpla, Edward, esq. Liverpool.
Dempster, J. esq. Commercial-ct. Glasgow.
Denison, James, esq. South Lambeth.
Dent, William, esq. Wandsworth-common.
Devas, William, esq. Watling-street.
Dixon, William, esq. Liverpool.
Dixon, Francis, esq. Manchester.
Dixon, George, esq. Manchester.
Dobson, John, esq. 17, Bucklersbury.
Duff, William, esq. Liverpool.
Dugdale, Adam, esq. Manchester.
Dyson, Thomas F. esq. Liverpool.

E
Edgar, T. esq. 9, Billiter-square.
Edwards, Richard, esq. Seel-st. Liverpool.
Edwards, C. A. esq. Wandsworth.
Engstrom, Charles, esq. St. Mildred’s Ct.
Euing, W. R. esq. Liverpool.
Evans, Thomas, esq. Watling-street.
Eyes, Charles, esq. Liverpool.

F
Fitzwilliam, the Right Hon. the Earl, 4, Grosvenor-square.
Farrer, William, esq. Watling-street.
Fawcett, Peter, esq. Manchester.
Fawdington, William, esq. Manchester.
Fell, Richard, esq. Bolton.
Fielding, Jeremiah, esq. 64, Mosley-street, Manchester.
Fisher, John, esq. 23, Watling-street.
Fleming, T. esq. Water-st. Manchester.
Forrester, W. esq. 3, Crown-ct., Broad-st.
Fortunato, A. P. esq. Liverpool.
Fothergill, J. esq. Stockwell-place, Surrey.
Fox, E. B. esq. 80, Old Broad-street.
Freeze, J. H. jun. esq. Mecklenburgh-sq.
Frend, William, esq. Rock Life Assurance, Bridge-street.
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

textbookfull.com

You might also like