Automata Theory
Automata Theory
I - COMPUTABILITY
ALGORITHMS AND ALGORITHMIC LANGUAGE:
An effective procedure is a finite, unambiguous description of a finite set of operations. the
operations must be effective in the sense that there is a statistically mechanical procedure for
completing them. Also, the process of deciding the order in which to perfom operations must be
effective. An effective procedure may perform a task, compute a function or just perform a
sequence of unrelated operations; examples are computer programs.
An effective procedure which specifies a sequence of operations which always halts is called an
algorithm. Thus, computer program which always halt for any input, i.e., never go into an
infinite loop, are algorithms.
Effective procedures will be written as finite sets of sentences, called statements, of languages
which are designed to expedite the representation of effective procedures. These algorithmic
languages may either be carefully chosen unambiguous subsets of natural languages or artificial
languages such as ALGOL, PASCAL or X-calculus.
There are many interesting problem which are not solve by effective procedures. For example,
there is no effective procedure in the language for deciding whether or not any two arbitrary
chosen effective procedures solve the same problem (i.e., are equivalent). Also, there is no effect
solution admitting whether an effective procedure written in an algorithm language is actually an
algorithm, that is, will always halt.
Problems which have an effective solution are said to be decidable, effectively solvable or
computable. All other problems, such as the halting problem for algorithmic language are said to
be undividable or noncomputable.
v. x− y = {x−0 y if x ≥ y
otherwise
, is the proper subtraction.
k+1 k 0
vi. x =x . x , where x =0 , is the concatenation.
Note that 0. x=x .0=x for all x ∈W ∧¿ x . ( y . z ) =( x . y ) . z for all x , y , z ∈W concatenation is
commutative so that ( x . y = y . x ) iff E contains only one letter but it is purely associative.
vii. ρ :W →W , where ρ ( 1212 )=2121 ;and ξ ( 11211) =11221in E2and
viii. 11213∈ E 3.
PL – COMPUTABLE FUNCTIONS
The PL program P computes the function f :W r →W s, if when stated with x 1 , … , x r as the values
of the variables x 1 , … , x r and with all other program variables initially o.
1. P halts with y 1 , … , y s as the values of the variables y 1 , … y3 respectively, if
( x 1 ,… , x r ) ϵ dom f ∧f ( x 1 , … , x r )= ( y 1 , … y r ) or
2. P never halts if f ( x 1 , … , x r ) is defined.
x 1 , … , x r∧ y 1 , … y s are called the input and output variables, respectively.
If there is a P which computes f, then f is a said to be PL – computable.
According to the definition given, each PL program computes different function f :W r →W s, for
each r , s ≥0 . There is requirement that the variables x 1 , … , x r and y 1 , … y s action appear in the
program, since there is the convention, the variable, except the input variables x 1 , … , x r is
initialize.
TURING MACHINE: The Turing machine has a single two-way work tape, divided into
squares each of which can contain a symbol from a finite alphabet. At each instance of time, the
tape’s re write head scams a single square. Based on the contents of square scanned, the
instruction executed will select the instruction and either change the symbol scanned or move
head one square right or left.
Finite Control
Unit
More formally, it can be described as a set of quintuples of the form ( q ,r , r ' , M , q' ). The q and q '
are the states of the machine. The symbol stands for a MOVE which may be R or L (and
sometimes C) meaning more Right or Left (or (do not move). The symbol σ represents the
symbol on the of the tape scanned by the machine and σ ' is to be written in its place.
( q ,r , r ' , M , q' ) indicates that if the machine is in states q and q ' and a is the symbol scanned on
the tape, replace the a with the symbol b and move to the right one tape square and go to the state
'
q.
II FORMAL LANGUAGES
list list
digit digit
digit
5 ¿ 2 +¿ 9
Types of Grammar
Grammar can be classified into different types, according to the form of productions allowed.
This is due to the fact that imposing restrictions on productions makes them much easier to
parse. The following is a summary of Chomsky classification.
TYPE 0 GRAMMAR: These are the most general and are also known as ‘free grammars’.
Productions are of the form u → v , where both u∧v are arbitrary strings of symbols in V, with u
non-null.
TYPE 1 GRAMMAR: These are known as ‘context-sensitive’ grammars. Productions are of the
form u X w → u v w , where u , v ,∧w are arbitrary strings of symbols in V, with v non-null and X
is a single non-terminal. Thus, X may be replaced by v but only when it is found surrounded by
u∧w .
TYPE 2 GRAMMAR: These are known as ‘context-free’ grammars. Productions are of the
form X → v , where v is an arbitrary string of symbols in V and X is a single non-terminal. Thus,
X may be replaced by v whenever it is found. The grammars used by syntax analysis in
compilers are type 2 grammars. They are normally defined by BNF (Backus-Naur Form)
notation. All languages derived from type 2 grammar can be parsed, but there are some subsets,
commonly used for programming language definition, that can be parsed particularly efficiently.
TYPE 3 GRAMMAR: These are more commonly called ‘regular grammars’. Productions are of
the form X → a∨ X →aY , where X ∧Y are non-terminal and a is a terminal. These grammar are
widely used in the lexical analyzers of compilers to describe the basic entities that make up the
programming language, though they are not generally enough to describe the syntax of a
complete programming language. Languages defined by type 3 grammars can be parsed vary
efficiently. In particular, they can always be recognized by a finite state info.
PROPERTIES OF GRAMMARS
1. EQUIVALENT GRAMMARS: Two grammars G and G’ are said to be equivalent if the
languages they generate L(G) and L(G’) are the same, though not necessarily the same parse
trees for each sentence. E.g., G : A → Ax| y ; G ’ : A → yB ; B → xB|ϵ .
Note that the parse trees are markedly different for the sentence yxx . Since parse tree often
reflects the semantic structure of a language, rewriting a grammar to make it easier to parse
may result in the loss of semantic information. Instead, a different parsing technique should
be used rather than rewriting or transforming the grammar.
2. AMBIGUOUS GRAMMARS: A grammar is said to be ambiguous if it has more than one
parse tree generating a given string of tokens. An ambiguous grammar can be resolved either
by either rewriting the grammar or by using disambiguating rules.
Illustration: To show that the grammar defined by 9+5∗2 is ambiguous using the
following grammar production:
E→T∗F | E+T
T →F
F→0|1|2|3| 4| 5|6|7| 8|9
3. RECURSIVE GRAMMARS: A production of a grammar is said to recursive if it is defined
in terms of itself in one of its attractive on the right hand side. E.g., variable_list→variable |
variable_list, variable. Productions of this form are said to be left-recursive, and have the
general form: A → u∨ A v , where A is a non-terminal and u and v are arbitrary strings of
terminals and non-terminals. Similarly, right-recursive productions have theirs in one of their
right-hand side alternatives occurring at the right-end. They have the general form
A → u∨v A . Left-recursive productions are a source of problem with some parsing methods.
There is, therefore, a standard transformation to give an equivalent grammar that is right-
recursive. E.g. A → u∨ A v can be replaced as: A → u B B → v B∨ϵ .
4. LEFTMOST AND RIGHTMOST DERIVATIONS: A leftmost derivation is a parse tree
in which we always expand the leftmost non-terminal first; and a parse in which we always
expand right-most non-terminal of the production first is a right-most derivation.
5. LEF FACTORING: This is a method by which an equivalent grammar is generated from
productions with identical first parts to alternative right-hand sides. E.g., X → v w can be
written as: X → v B ; B → w∨z equivalently. Left factoring can be very helpful in syntax
analysis.