Sunteți pe pagina 1din 3

Tahir Naseem/Handout 2

-1-

Theory of Automata and Formal Languages

Lecture 2
Objectives
What are Formal Languages
o Why to Study Formal Languages
Some Kinds of Machine
Grammar
Basic Definitions and Notations
o Alphabets
o Strings
o Empty String
o Length
o Languages
What are Formal Languages
A language in which all rules for language are explicitly stated.
A formal language is a set of wordsthat is, strings of symbols drawn from a
common alphabet (a finite set of symbols, letters, or tokens from which the words of
the language may be formed).
A formal language is often defined by means of a formal grammar (also called its
formation rules).
Words that belong to a formal language are sometimes called well-formed words or
well-formed formulas.
Formal languages are studied in computer science and linguistics.
The field of formal language theory studies the purely syntactical aspects of such
languagesthat is, their internal structural patterns.
In computer science, formal languages are often used as the basis for defining
programming languages and other systems in which the words of the language are
associated with particular meanings or semantics.
o Software for parsing formal languages may be generated by means of a
compiler,
often separated into a lexical analyzer and parser generator.
In computational complexity theory, decision problems are typically defined as
formal languages, and complexity classes are defined as the sets of the formal
languages that can be parsed by machines with limited computational power.
In logic and in the foundations of mathematics, formal languages are used to
represent the syntax of formal theories. Logical systems can be seen as a formal

Tahir Naseem/Handout 2

-2-

Theory of Automata and Formal Languages

language with additional constructs, like proof calculi, which define a consequence
relation.
Why to Study Formal Languages
Formal languages are studied to define things (problems) precisely
Formal statements have one and only one meanings unlike informal languages
Example
o Informal: It's so obvious that people were given jobs just because they were
male or female. I don't think that is an acceptable approach and is even against
the law
o Formal: It appears that in a number of instances jobs were assigned on the
basis of gender. Given the current anti-discrimination laws, this raises serious
concerns.
Some Kinds of Machine
Finite automata: Devices with a small amount of memory. Used to model very
simple things.
Push-down automata: Devices with infinite memory that can be accessed in a
restricted way. Used to parse grammars
Turing Machines: Devices with infinite memory. These are the real computers
Time-bounded Turing Machines: Infinite memory, but bounded running time.
These are computers that run reasonably fast.

Grammar
Grammars describe the meaning of sentences in English, and the meaning of
programs in programming language
We will see how to extract the meaning out of a program
It is useful when designing software that process data with a recursive structure
o Parser
Alphabets
An alphabet is a finite, non empty set of symbols.
Conventionally, we use the symbol for an alphabet
o 1 = {0, 1} binary alphabet
o 2 = {a, b, c,,z} the set of lowercase letters in English
o 3 = {0, 1, 2, , 9} the set of base 10 digits

Tahir Naseem/Handout 2

-3-

Theory of Automata and Formal Languages

o 4 = {a, b, c, , z, #} the set of lowercase letters in English and special


character #
String
A
string
over
of symbols in .

alphabet

is

finite

o abfbz is a string over 1 = {a, b, c, d, , z}


o 9021 is a string over 2 = {0, 1, , 9}
o ab#bc is a string over 3 = {a, b, , z, #}
Empty String
A string with zero occurrences of symbols.
The empty string will be denoted by
Length
Number of symbols in string, and notation is |S| where S is a string
The length of empty string will be zero and be denoted as
o || = 0
The length of abbbab is 6 as
o |abbbab| = 6
Languages
A language is a set of strings over the same alphabet ( ).
It is denoted by L.

sequence

S-ar putea să vă placă și