Professional Documents
Culture Documents
Formal Languages
Dr. Osama Fathy
Lecture 1
Introduction
Overview
• Important information
• Language
• Examples
• Terminology
• Other things we will cover in the course.
Text Books
Prescribed Text:
Daniel I.A. Cohen, “Introduction to Computer
Theory”, Second Edition, John Wiley & Sons, 1997
Recommended Reading:
– John E. Hopcroft, Rajeev Motwani, and Jeffrey
Ullman, “Introduction to Automata Theory
Languages and Computation”, 2nd Ed., Addison
Wesely, 2001
Theory of Computer – ToC (Computation Theory)
Algorithm
Formal refer to the fact that all rules for a language are
explicitly stated in terms of:
what strings of symbols can occur.
No liberties are tolerated, and
no reference to any deep understanding is required.
• Natural Languages
– English, Chinese, French, etc.
• Programming Languages
– C, MIPS, BASIC, Fortran, Pascal, etc.
• Mathematics
• State Diagrams
• Music
Components
• Alphabet
– Basic elements
• Rules
– Grammar
– Tell you what words belong to the language
– Syntax
• Meaning
– semantics
Definitions
Alphabet (∑)
A finite set of fundamental units out of which we
build a structure (word or string).
Language (L)
Certain specified set of strings of characters from an
alphabet.
Word (w)
Is a string that permissible in a language.
Empty String or null string (Λ)
Is a string with no letters.
Grammar:
Rules for deriving & parsing strings in some language.
Notes:
A language has three entities: letters, words and sentences.
•L ≠ L + {Λ}
•L + Φ = L
English-Words
• Alphabet
a b c .. z A B .. Z ’ -
• Words
– all the words in a standard dictionary
– e.g.
don’t context-free regular …
English-Sentences
• Alphabet
– English words
– punctuation marks
?!,‘’;:
– blank space
• Words
– sentences
What is on the exam?
The quick brown fox jumped over the lazy dog.
C-Language
• Alphabet
– ASCII characters
• Words
– programs
#include<stdio.h>
int main()
{
printf (“Hello\n”);
}
Languages
Two examples
English-Words English-Sentences
alphabet Σ ={a,b,c,d,…} Σ =words in dictionary +
space + punctuation marks
• Alphabet
ab
• Words
a b ab abbb bab …
• Notation
a2 means aa
b3 means bbb
• Empty Word Λ
• Empty Language φ
Languages
Example: Σ ={x}
• L1={x, xx, xxx, xxxx,…} or L1={xn | n=1, 2, 3,…}
Σ∗ = {Λ, x, xx, xxx, xxxx,…} ={xn | n=0, 1, 2, 3,…}
We denote x0 = Λ
Σ= {0, 1}
L1 = set of all words in Σ∗ starting with 1 and with length
at most three
= {1, 10, 11, 101, 100, 110, 111}
Languages
u = u1u2…um v = v1v2 … vn
uv = u1u2…um v1v2 … vn
Example: Σ={0, 1}
L1 = {u in Σ∗: the number of zeros in u is even}
L2 = {u in Σ∗: u starts with a 0 and all the remaining characters are 1’s}
L1L2 = {u in Σ∗: the number of zeros in u is odd}
Languages
• Examples:
Σ = {x} Σ+ = {x, xx, xxx, …}
S = {aa, bbb, Λ} S+ = {aa, bbb, Λ, aaaa, aabbb, …}
( aΛ = a)
Languages
• Example:
S = {a, b, ab} T = {a, b, bb}
S* = T* although S ≠ T
ab|a|a|ab|ab|a
a|b|a|a|a|b|a|b|a
EVEN-EVEN-Language
• e.g.
Λ aa bb aaaa aabb abab abba baab
DOUBLEWORD-Language
• All the strings are formed by two copies of a string joined
together.
• {ss : s is a string of a and b}
• e.g.
Λ aa bb aaaa abab baba bbbb
PALINDROME Language
•All the strings which are the same if they are spelt backwards
Example: PALINDROME
Σ={a, b}
PALINDROME:={Λ and w in Σ∗| reverse(w) = w}
= {Λ, a, b, aa, bb, aaa, aba, bbb, bab, … }