Click here to load reader
Sep 06, 2018
1
Automata and Formal Languages
Winter 2009-2010
Yacov Hel-Or
2
What this course is all about
This course is about mathematical modelsof computation
Well study different machine models (finite automata, pushdown automata, Turing machine)
and characterize what they can compute
3
Why should I care ?
To understand the limits of computationsSome problems require more resources to compute
and others cannot be computed at all.
To learn some programming tools Automata show up in many different settings:
compilers, text editors, hardware design, communication protocols, program proofing,
To learn to think in a formal way about computing
4
Computability and Complexity
Are there any problems that can not be solved by a (very powerful) computer?
What makes some problems computationally hard and other easy?
Can we partition the problems into classes such that problems in one class share the same computational properties?
Complete answers: next semester.
Introduction, basic tools, models, intuition: this semester.
5
This Course: Formal computational models
The basic computational model : Finite State Automata
Additional models: Pushdown automaton
Turing machine
Formal languages Regular languages
Context free languages
6
Administration
Course Home page: http://www1.idc.ac.il/toky/Automata
Lecture notes will appear at the course web-page the day before the lecture (the latest).
Proofs, examples, technical details will usually be presented on the board.
No recitations, part of lecture time will be dedicated to solving problems.
Grade calculation: Exam 70%, HW 30%
Exam: Must pass the exam (60) in order to have the HW component.
7
Administration (cont.)
HW: Will be given every week.
Submission: Wednesdays before your lecture.
Appeals: No more than two weeks after return.
Grader + TA: Ilit Raz ([email protected])
Newsgroup: news://news.idc.ac.il/automata
Book: Sipser (see web-page for details).
8
Unit 1
IntroductionMathematical Background
Reading: Sipser, chapter 1
Today
Set theory (review?)
Logic, proofs (review?)
Words and their operations:
Languages and their operations:
9
wwwww i ,,, *21 LLLLL i ,,, *21
10
Set TheoryA Set is a group of objects.The objects are called elements.
Notation:
1. By listing the elements. Examples: {3,5,7} ,{Alice, Bob, {1,2} } (for finite sets only)
2. By providing a rule. Examples:
{x | x is an odd integer between 2 and 8} ;
{x | name of a student in the Automata class}
A name of a set is usually a capital letter of theEnglish alphabet (A, B, C) or a capital letter withan index (X1 , X2 , X3)
,
11
The Empty Set
A set with no elements is called an empty set.
Notation or { }
Example:
S - a set of all odd numbers that can be dividedby two without any remainder.
S is an empty set.
S = {xN | x is odd and x mod 2=0}=
12
Membership in a set
s S , means that an element s is a memberof the set S
b S, means that an element b is not a member of the set S
Examples: 7 {21,7,30} and 8 {21,7,30}
Let N be the set of natural numbers.2 N and 3.2 N
13
Subsets
Given two sets A and B we say that A is asubset of B, if each element of A is also anelement of B.
The notation: A B Formally: A B x A x B
Example:A set of natural numbers N is a subset of a
set of all real numbers R.N R
14
Proper Subset
Given two sets A and B we say that A is aproper subset of B if each element of A isalso an element of B and there exists atleast one element in B that does not belongto A.
The notation: A B
Example:{1,3} {1, 2, 3, 8}
15
Some Facts
Each set is a subset of itself:
A A
The empty set is a subset of every set:
A
16
More on Sets
Two groups of elements that have the same elements but in different order form the same set.
Example: If A = { 1,2,3,4}, B = { 2,1,4,3} then A = B
Repetitions in a set are irrelevant
Example: {1,2,3,4,2} = {1,2,3,4}
17
More on Sets
The cardinality of a set is the number ofelements in the set. Notation: |A|
Example: Let A = { 1,2,4,8,16}, then |A|=5
A set can be:
Finite A={Even integers smaller than 100}
Infinite A={Even integers dividing 7 with no reminder}
18
Operations on sets union
intersection
complement
difference
A visual model, called Venn diagram can be used.
A
19
Venn Diagram
Start-t End-z Start-j
terrifictheory topaz jazz
20
Union
A binary operation
The notation : A B
Formally:
A B = { x | xA or xB }
A B
21
Intersection
A binary operation
The notation: A B
Formally:
A B = { x | xA and xB }
A B
22
Complement
An unary operation
The notation : ~A
Formally:
~A = { x | x A}
A
23
Set Difference
An binary operation
The notation : A-B
Formally: A-B = { x | xA and x B}
Example: A = { 1,2,3 }, B={3,4,5}, A-B={1,2}
A B
24
Power Set
The power set is the set of all subsets of a given set.
Notation: P(S) or 2S is a power set of S
Note, that sets may appear as elements of other sets.
The cardinality of a power set is: 2|S|
(why?)
Example:S = { 1,2 }P(S) = 2S = { ,{1},{2},{1,2}}
25
Sequences and Tuples
A sequence of objects is a list of objects in some order.
The notation : (7,21,57,)
Unlike sets, the order and repetitions in the sequence do matter, thus
(7,21,57) (7,57,21) and (7,21,57,57) (7,21,57)
A sequence with k elements is a k-tuple
Example: (7,21,57) is a 3-tuple.
-
26
Cartesian product
A binary operation
The Cartesian product (or cross product) is a set of all pairs (2-tuple) where the first element of the pair is in A and the second element of the pair is in B.
The notation: AB
A Cartesian product of a set with itself:
AAA (k times)=Ak
Example:
A = {2,3}, B = {b,c}, AB ={ (2,b), (2,c), (3,b), (3,c) }
Summary: sets
,{ } empty set
a A membership
|A| cardinality
AB subset
AB union
AB intersection
~A complement
A-B set difference
2A power set
(a,b,..) a sequence (k-tuple)
AxB cartesian product 27
28
Letters and Alphabet
Any finite set of letters (symbols) is called an alphabet.
Notation: alphabet- ; Letter (symbol)-
Examples:
1 = { 0,1 } , 1=0 ; 2=1;
2 = { a,b,c,d,e, }, 1=a ; 2=b ; 3=c ;
3 = { 0,1,x,y,z}
,
29
Strings (and words)
A string (word) over some alphabet is a finite sequence of letters from the alphabet.
Example: = {0, 1}, w = 101
The length of a word, w, denoted |w|, is the number of letters in it.
Example:
w1 = abracadabra; |w1| = 11
w2 = 001011 ; |w2| = 6
, ,
30
More on Strings An empty word is a string without letters.
The notation of an empty word is
|| = 0
The number of occurrences of some letter in word w is denoted by #(W)
Example:
Let w=aaba, then #a(w)=3, #b(w)=1, #c(w)=0
31
Operations on Strings
reverse
sub-string
prefix
suffix
concatenation
32
Reversing strings
A reverse string is a string in which all letters are written in the opposite order
Notation: wR
Examples:w = 10, wR = 01
s = abcb, sR = bcba
A palindrome: a string w such that w=wR.
Examples: aba, 010010,
33
Sub-strings
A sub-string is a subsequence of consecutiveletters from a string
Example: Let w = 101. All sub-strings of w are:
B(w) = { , 1, 0, 10, 01, 101 }.
Note: 11 B(w)
34
Prefixes A prefix is a sub-string which starts from
the first letter of the word (or an empty word).
A proper prefix of a string is a prefix that is not equal to the complete word.
Example: Let w = acdb. The prefixes of w are { , a,ac,acd,acdb}. acdb is not a proper prefix.
,
35
Suffixes A suffix is a substring ending with the last
letter of the word or an empty word.
A proper suffix of the string is a suffix that is not the whole word.
Example: Let w = acdb. The suffixes of w are { ,b, db,cdb,acdb}. acdb is not a proper suffix
Note: The prefixes of w are the reversed suffixes of wR.
,
36
Concatenation
A binary operation (over two words)
The concatenation of two words x and yplaces them one after the other such thatthe first word is a prefix and a second oneis a suffix.
Notation: concatenation of two words x andy: xy
Example: Let x= 01, y=012, z=10
Then xy=01012, yx=01201, xyz=0101210
37
Concatenation (Cont.)
The result of concatenating a word with anempty word is the string itself. Forexample