Formal Languages and Automata (Intro)
Why Formal Languages and Automata?
- A study of abstract models of computers and computation.
- Highly used in computer-related career. (e.g.,
, network protocols, electronic circuits, etc. )
How to do that?
- Context-free grammars are used to describe the syntax of essentially every programming language.
- Automata theory gives you the tools to developing solutions to real problems.
Limit of Computation
Software developing is often confronted with the problem of complexity. Formal languages and automata theory can help you to understand the limits of computation. Here are two important concepts:
- Undecidable things – no program whatever can do it.
- Intractable things – there are programs, but no fast programs.
Preliminaries
Elementary Mathematical Knowledge
- Basic set theory: union, intersection, difference, complement,
Laws, subsets, set cardinality (the size of set), product, power set (the set of all subsets), etc. (Refer to Set Theory in mathematical logic.) - Relations: reflexive, symmetric, transitive, equivalence relations, functions, partial orders, total order, linear order, etc. (Refer to Relations in mathematical logic.)
- Complexity:
and notations, etc. - Graph theory: directed and undirected graphs, reachability, trees, etc.
- proof techniques: proof by induction, proof by contradiction, etc.
Languages
A language is a set of strings. A string is a sequence of symbols. Symbols are defined over an alphabet. Alphabet is a set of symbols, often denoted by
We have the following string operations:
- Concatenation:
is the concatenation of strings and . - Power:
is the concatenation of copies of string . E.g., . - Reversal:
is the reversal of string . E.g., . - Get Length:
is the length of string . Obviously, we have
We need to define the empty string
Substring of a string is a subsequence of consecutive characters in that string. For example, "abc" is a substring of "abcde". From this definition, we can easily define the prefix and suffix of a string. For example, "ab" is a prefix of "abcde", and "de" is a suffix of "abcde".
Question
Given the equation
Solution:
- If
, then ok. - If
, then no solution. - If
, then no solution. - If
, then . Hence, . So, . Therefore, .
We have the following operations on Alphabets:
-operation: is the set of all strings over , including the empty string . -operation: is the set of all strings over except the empty string .
Language is a set of strings, is any subset of
We have the following operations on Languages:
- Usual set operations: union, intersection, difference, complement, etc.
- Concatenation:
. Like concatenation in symbols, we write to denote the concatenation of copies of .
Note that...
Suppose that
- Star-Closure:
. It is the set of all strings that can be formed by concatenating zero or more strings from , or may say, the "dictionary" of .