Languages and Finite Automata - PowerPoint PPT Presentation

About This Presentation
Title:

Languages and Finite Automata

Description:

Slides by Costas Busch, Rensselaer Polytechnic Institute, ... Pigeon Hole Principle: If n 1 objects are put into n boxes, then at least ... – PowerPoint PPT presentation

Number of Views:86
Avg rating:3.0/5.0
Slides: 58
Provided by: cost80
Learn more at: http://web.cs.wpi.edu
Category:

less

Transcript and Presenter's Notes

Title: Languages and Finite Automata


1
Introduction to Theoretical Computer
Science COMP 335 Fall 2004 Slides by Costas
Busch, Rensselaer Polytechnic Institute, Modified
by N. Shiri G. Grahne, Concordia University
2
  • This course A study of
  • abstract models of computers and computation.
  • Why theory, when computer field is so practical?
  • Theory provides concepts and principles, for both
    hardware and software that help us understand the
    general nature of the field.

3
Mathematical Preliminaries
4
  • Mathematical Preliminaries
  • Sets
  • Functions
  • Relations
  • Graphs
  • Proof Techniques

5
SETS

A set is a collection of elements
We write
6
Set Representations C a, b, c, d, e, f, g,
h, i, j, k C a, b, , k S 2, 4, 6,
S j j gt 0, and j 2k for kgt0 S
j j is nonnegative and even
finite set
infinite set
7
A 1, 2, 3, 4, 5
Universal Set all possible elements
U
1 , , 10
8
  • Set Operations
  • A 1, 2, 3 B 2, 3, 4, 5
  • Union
  • A U B 1, 2, 3, 4, 5
  • Intersection
  • A B 2, 3
  • Difference
  • A - B 1
  • B - A 4, 5

2
4
1
3
5
U
2
3
1
Venn diagrams
9
  • Complement
  • Universal set 1, , 7
  • A 1, 2, 3 A 4, 5, 6, 7

4
A
A
6
3
1
2
5
7
A A
10
even integers odd integers
Integers
1
odd
0
5
even
6
2
4
3
7
11
DeMorgans Laws
A U B A B
U
A B A U B
U
12
Empty, Null Set

S U S S S - S
- S
U
Universal Set
13
Subset
A 1, 2, 3 B 1, 2, 3, 4,
5
Proper Subset
B
A
14
Disjoint Sets
A 1, 2, 3 B 5, 6
A
B
15
Set Cardinality
  • For finite sets

A 2, 5, 7 A 3
(set size)
16
Powersets
A powerset is a set of sets
S a, b, c
Powerset of S the set of all the subsets of S
2S , a, b, c, a, b, a, c, b,
c, a, b, c
Observation 2S 2S ( 8 23 )
17
Cartesian Product
A 2, 4 B 2, 3, 5 A
X B (2, 2), (2, 3), (2, 5), ( 4, 2), (4, 3),
(4, 5) A X B AB Generalizes to more
than two sets A X B X X Z
18
FUNCTIONS
domain
range
B
A
4
f(1) a
a
1
2
b
c
3
5
f A -gt B
If A domain then f is a total function
otherwise f is a partial function
19
RELATIONS
R (x1, y1), (x2, y2), (x3, y3),
xi R yi e. g. if R gt 2 gt 1,
3 gt 2, 3 gt 1
20
Equivalence Relations
  • Reflexive x R x
  • Symmetric x R y y R x
  • Transitive x R y and y R z
    x R z
  • Example R
  • x x
  • x y y x
  • x y and y z x z

21
Equivalence Classes
For an equivalence relation R, we define
equivalence class of x xR y x R
y Example R (1, 1),
(2, 2), (1, 2), (2, 1), (3, 3),
(4, 4), (3, 4), (4, 3) Equivalence class of
1R 1, 2 Equivalence class of 3R 3, 4
22
GRAPHS
A directed graph GltV, Egt
e
b
node
d
a
edge
c
  • Nodes (Vertices)
  • V a, b, c, d, e
  • Edges
  • E (a,b), (b,c), (b,e),(c,a), (c,e),
    (d,c), (e,b), (e,d)

23
Labeled Graph
2
6
e
2
b
1
3
d
a
6
5
c
24
Walk
Walk is a sequence of adjacent edges
(e, d), (d, c), (c, a)
25
Path
A path is a walk where no edge is repeated A
simple path is a path where no node is repeated
26
Cycle
e
base
b
3
1
d
a
2
c
A cycle is a walk from a node (base) to itself A
simple cycle only the base node is repeated
27
Trees
root
parent
leaf
child
Trees have no cycles Ordered trees?
28
root
Level 0
Level 1
Height 3
leaf
Level 2
Level 3
29
PROOF TECHNIQUES
  • Proof by induction
  • Proof by contradiction

30
Induction
We have statements P1, P2, P3,
  • If we know
  • for some b that P1, P2, , Pb are true
  • for any k gt b that
  • P1, P2, , Pk imply Pk1
  • Then
  • Every Pi is true, that is, ?i P(i)

31
Proof by Contradiction
  • We want to prove that a statement P is true
  • we assume that P is false
  • then we arrive at an incorrect conclusion
  • therefore, statement P must be true

32
Example
Theorem is not rational Proof Ass
ume by contradiction that it is rational
n/m n and m have no common
factors We will show that this is impossible
33
n/m 2 m2 n2
n is even n 2 k
Therefore, n2 is even
m is even m 2 p
2 m2 4k2
m2 2k2
Thus, m and n have common factor 2
Contradiction!
34
Pigeon Hole Principle If n1 objects are put
into n boxes, then at least one box must contain
2 or more objects. Ex Can show if 5 points are
placed inside a square whose sides are 2 cm long
? at least one pair of points are at a distance
?2 cm. According to the PHP, if we divide the
square into 4, at least two of the points must be
in one of these 4 squares. But the length of the
diagonals of these squares is ?2. ? the two
points cannot be further apart than ?2 cm.
35
Languages
36
  • A language is a set of strings
  • String A sequence of letters/symbols
  • Examples cat, dog, house,
  • Defined over an alphabet

37
Alphabets and Strings
  • We will use small alphabets
  • Strings

38
String Operations
Concatenation
39
Reverse
40
String Length
  • Length
  • Examples

41
Length of Concatenation
  • Example

42
The Empty String
  • A string with no letters
  • Observations

43
Substring
  • Substring of string
  • a subsequence of consecutive characters
  • String
    Substring

44
Prefix and Suffix
  • Prefixes Suffixes

prefix
suffix
45
Another Operation
  • Example
  • Definition

46
The Operation
  • the set of all possible strings from
  • alphabet

47
The Operation
the set of all possible strings from
alphabet except
48
Languages
  • A language is any subset of
  • Example
  • Languages

49
Note that
Sets
Set size
Set size
String length
50
Another Example
  • An infinite language

51
Operations on Languages
  • The usual set operations
  • Complement

52
Reverse
  • Definition
  • Examples

53
Concatenation
  • Definition
  • Example

54
Another Operation
  • Definition
  • Special case

55
More Examples

56
Star-Closure (Kleene )
  • Definition
  • Example

57
Positive Closure
  • Definition
Write a Comment
User Comments (0)
About PowerShow.com