Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
BATTERY
input: switch
output: light bulb
actions: flip switch
states: on, off
A simple “computer”
input: switch
output: light bulb bulb is on if and only if
there was an odd number
actions: f for “flip switch” of flips
states: on, off
Another “computer”
1
1 start off off
1
2 2 2 2
BATTERY
1
2
off on
1
▫ Versus
• aa + aba
= aaaba
Kleene Closure
• Given an alphabet ∑ we wish to define a
language in which any string from letters of ∑ is
a word, even the null string
• This language is referred to as the closure of the
alphabet
• Denoted by ∑*
• Also referred to as the Kleene star
Example 1
• If ∑ = {x}
• ∑* = {λ a b c aa ab ac ba bb bc ca cb cc
aaa …}
Kleene Star
• An operation that makes an infinite language of
strings of letters out of an alphabet
• Note that the words are sequenced by size, in
lexicographic order (size order-all words of the
same length alphabetically)
• Normal alphabetical ordering would not enable
a listing that would inform us of the nature of
the language
• In the case of the last example {λ a aa aaa
aaaa}
Generalizing *
DEFINITION
If S is a set of words, then by S* we mean the set
of all finite strings formed by concatenating
words from S, where any word may be used as
often as we like, and where the null string is also
included.
Example 4
• S = {aa b}
• S* = {λ plus any word composed of factors of aa
and b}
• = {λ plus all strings of a’s and b’s in which the a’s
occur in even clumps}
• = {λ b aa bb aab baa bbb aaaa aabb baab
bbaa bbbb aaaab aabaa aabbb baaaa baabb
bbaab bbbaa bbbbb …}
• Is aabaaab in S*?
• No (aabaaab)
Example 5
• S = {a ab}
• S* = {λ plus any word composed of factors of a and ab}
• = {λ plus all strings of a's and b's except those that start
with b and those that contain a double b}
• = {λ a aa ab aaa aab aba aaaa aaab aaba abaa abab
aaaaa aaaab aaaba aabab abaaa abaab ababa ... }
• Is abaab part of S*?
• To prove that abaab is in S*, factor it as
▫ (ab)(a)(ab)
▫ This is the only way this string can be factored, so it is
referred to as a unique factorization
Factoring
• Factoring is not always unique
• S = {xx xxx}
• S* = {λ and all strings of more than 1 x}
• = { xn for n = 0 2 3 4 5 ... }
• = {λ xx xxx xxxx xxxxx xxxxxx ... }
• xxxxxxx
▫ (xx)(xx)(xxx)
▫ (xx)(xxx)(xx)
▫ (xxx)(xx)(xx)
• x6 = x2x2x2 or x3x3
Factoring
• The parentheses () in the previous example were
not letters of the alphabet
• There can be cases where they are
• ∑={x()}
▫ length(xxxxx)
=5
▫ length((xx)(xxx))
=9
Proof by Constructive Algorithm