cs466 (prasad)l1sets1 introduction language: set of strings
TRANSCRIPT
CS466 (Prasad) L1Sets 2
• Specification and recognition of languages
• Sets• Operations
• Defining sets (inductively)
• Proving properties about sets (using induction)
• Defining functions on sets (using recursion)
• Proving properties about functions (using induction)
• Strings• Operations
• Languages : set of strings• Operations
CS466 (Prasad) L1Sets 3
Representation of Sets
• Set: collection of objects– Finite : can use enumeration
• E.g., {a,b,c}
– Infinite : requires describing characteristic property of members finitely
• E.g., { n N | even(n) /\ square(n) }
• COURSE GOAL: Study techniques for finitely describing specific families of sets
CS466 (Prasad) L1Sets 4
Semantics - Syntax
• Regular sets/languages– Generator
• Regular Expressions, Regular Grammars
– Recognizer• Finite State Automata
• Context-free languages– Generator
• Context-free Grammar
– Recognizer• Push-down Automata
CS466 (Prasad) L1Sets 5
• Member, Union, Intersection, Subset, Powerset, Cartesian product, …
• Set Difference
• DeMorgan’s Laws
Operations on Sets
X Y Y X
Y} z X { z | z Y X
,...,,,,
YXYX
YXYX
CS466 (Prasad) L1Sets 6
Partition of a Set X
The set
of non-empty subsets of X is a partitionpartition of X iff(1) “covering”
(2) “pair-wise disjoint”
Collectively Exhaustive / Mutually Exclusive
},...,,{ 21 nXXX
XXXX n ...21
)()( ji XXji
CS466 (Prasad) L1Sets 7
Examples• Set of Natural numbers is partitioned by
“mod 5” relation into five “equivalence classes”:{ {0,5,10,…}, {1,6,11,…}, {2,7,12,…}, {3,8,13,
…}, {4,9,14,…} }
• “String length” can be used to partition the set of all bit strings.{ {},{0,1},{00,01,10,11},{000,…,111},… }
CS466 (Prasad) L1Sets 11
One to one correspondence Function
(bijection)
BAf :
A B
f
Domain Co-domain ( Range)
CS466 (Prasad) L1Sets 12
Inductive Definitions
• Constructive
• Example– Set of natural numbers
N = {0,1,2,3,…}
– Finite representation in terms of Seed element: zero
Closure Operation: successor function
{0,s(0),s(s(0)),s(s(s(0))),…}
– Imposes additional structure on the domain.
CS466 (Prasad) L1Sets 13
• Basis case:
• Recursive step:
• Closure: only if it can be obtained from 0 by a finite number of applications of the operation s.
(* Minimality condition to uniquely determine N *)
0
)(nsn
n
CS466 (Prasad) L1Sets 14
URLs for Visualizing Recursion
• http://math.rice.edu/~lanius/fractals/• http://www-mickunas.cs.uiuc.edu/java-book.old/
code/ch11/applets/HilbertApplet.html• http://www-mickunas.cs.uiuc.edu/java-book.old/
code/ch11/applets/SierpinskiApplet.html• http://www-mickunas.cs.uiuc.edu/java-book.old/
solutions/ch11/SierpinskiGasket.html
CS466 (Prasad) L1Sets 15
Recursive Definitions of Functions
• Addition– Basis case:– Recursive step:– Closure: …
• Multiplication– Basis case:– Recursive step:– Closure: …
mmm 0 :
)()( :, nmsnsmnm
00 : mm
nmmnsmnm *)(* :,
CS466 (Prasad) L1Sets 17
• Explicit Definition
• Implicit Definition
• Recursive Definition
),...}3,2(),2,1(),1,0(
),...,2,2(),1,1(),0,0{(
)1()( yxyx
0
1
0
}),(|)1,1{(
)}1,0(),0,0{(
ii
ii
LL
LjijiL
L
CS466 (Prasad) L1Sets 18
Other Recursive Definitions
0
1
0
}),(|)1,1{(
)}1,1(),1,0(),0,0{(
ii
ii
ML
MjijiM
M
}0,0{
}),(|)1,1{(
)}1,1(),1,0{(
0
1
0
ii
ii
NL
NjijiN
N
CS466 (Prasad) L1Sets 19
Observations
• Recursive definition of a set typically contains a finite number of seed elements and a finite number of rules to generate successive sets of points, whose infinite union yields the set.
• Even though the various definitions “look” different, they capture the same set.
Equivalence Problem.
CS466 (Prasad) L1Sets 22
Principle of Mathematical Induction
• Basis: PP holds for every element in
• Induction Step: If, whenever PP holds for every element in
PP also holds for every element in
then, by PMI,
PP holds for every element in
0L
,,...,, 10 iLLL1iL
L
0i
iLL
CS466 (Prasad) L1Sets 23
• Let be the Fibonacci number. Then, prove that
• Basis:
• Hypothesis:
• Prove:
nF thn
Example
110*1
)1( 12102
FFF
nnnn FFFn )1( :1 2
11
nFFFn )1( : 211
)1( :1 2
11 FFFn
CS466 (Prasad) L1Sets 24
• Proof
(Induction Hypothesis)
)1(
)1(
)1()(
)1()(
)1(
211
121
211
21
121
2111
1211
1212
FFF
FFFFF
FFFFF
FFFF
FFF n
CS466 (Prasad) L1Sets 25
Example• Strictly Binary Tree
• Single node.
• Every node is a leaf or has precisely two children.
• Prove that for all SBTs:2*leaves(T)-2 = arcs(T)
T1 T2
CS466 (Prasad) L1Sets 26
(Induction on the number of nodes or height.)
Basis: 2*1-2=0
Induction Hypothesis:
For trees of height h < , the result holds.
Induction Step: Show it holds for trees of height
2*leaves(T1)-2=arcs(T1) (induction hypothesis)
2*leaves(T2)-2=arcs(T2)
2*(leaves(T1)+leaves(T2))-2-2=arcs(T1)+arcs(T2)
2*leaves(T)-2=arcs(T)
0h
0h