SlideShare a Scribd company logo
Lecture 02: Theory of Automata
Theory of Automata
Lecture 02: Theory of Automata
2
Definition: Palindrome
• Let us define a new language called Palindrome over the
alphabet
∑ = { a, b }
PALINDROME = { Λ, and all strings x such that
reverse(x) = x }
• If we want to list the elements in PALINDROME, we find
PALINDROME = { Λ, a, b, aa, bb, aaa, aba, bab, bbb,
aaaa, abba, … }
Lecture 02: Theory of Automata
3
• Sometimes two words in PALINDROME when
concatenated will produce a word in PALINDROME
– abba concatenated with abbaabba gives abbaabbaabba (in
PALINDROME)
• But more often, the concatenation is not a word in
PALINDROME
– aa concatenated with aba gives aaaba (NOT in PALINDROME)
Palindrome
Lecture 02: Theory of Automata
4
Kleene Closure
• Definition: Given an alphabet ∑, we define a language
in which any string of letters from ∑ is a word, even the
null string Λ. We call this language the closure of the
alphabet ∑, and denote this language by ∑*.
• Examples:
If ∑ = { x } then ∑* = { Λ, x, xx, xxx, … }
If ∑ = { 0, 1 } then ∑* = { Λ, 0, 1, 00, 01, 10, 11,
000, 001, … }
If ∑ = { a, b, c } then ∑* = { Λ, a, b, c, aa, ab, ac,
ba, bb, bc, ca, cb, cc, aaa, … }
Lecture 02: Theory of Automata
5
• Note that we listed the words in a language in size order
(i.e., words of shortest length first), and then listed all the
words of the same length alphabetically.
• This ordering is called lexicographic order, which we will
usually follow.
• The star in the closure notation is known as the Kleene
star.
• We can think of the Kleene star as an operation that
makes, out of an alphabet, an infinite language (i.e.,
infinitely many words, each of finite length).
Lexicographic order
Lecture 02: Theory of Automata
6
• Let us now generalize the use of the Kleene star oprator
to sets of words, not just sets of alphabet letters.
• Definition: If S is a set of words, then S* is 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.
Kleene Closure
Lecture 02: Theory of Automata
7
• Example: If S = { aa, b } then
S* = { Λ plus any word composed of factors of aa and
b }, or
S* = { Λ plus any strings of a’s and b’s in which the a’s
occur in even clumps }, or
S* = { Λ, b, aa, bb, aab, baa, bbb, aaaa, aabb, baab,
bbaa, bbbb, aaaab, aabaa, aabbb, baaaa, baabb, bbaab,
bbbaa, bbbbb, … }
Note that the string aabaaab is not in S* because it has a
clump of a’s of length 3.
Kleene Closure
Lecture 02: Theory of Automata
8
• Example: Let S = { a, ab }. Then
S* = { Λ plus any word composed of factors of a and
ab }, or
S* = { Λ plus all strings of a’s and b’s except those that
start with b and those that contain a double b }, or
S* = { Λ, a, aa, ab, aaa, aab, aba, aaaa, aaab, abaa,
abab, aaaaa, aaaab, aaaba, aabaa, aabab, abaaa,
abaab, ababa, … }
• Note that for each word in S*, every b must have an a
immediately to its left, so the double b, that is bb, is not
possible; neither any string starting with b.
Kleene Closure
Lecture 02: Theory of Automata
9
• We must show how it can be written as a concatenation
of words from the base set S.
• In the previous example, to show that abaab is in S*, we
can factor it as follows:
abaab = (ab)(a)(ab)
• These three factors are all in the set S, therefore their
concatenation is in S*.
• Note that the parentheses, ( ), are used for the sole
purpose of demarcating the ends of factors.
How to prove a certain word is in the
closure language S*
Lecture 02: Theory of Automata
10
• Observe that if the alphabet has no letters, then its
closure is the language with the null string as its only
word; that is
if ∑ = ø (the empty set), then ∑* = { Λ }
• Also, observe that if the set S has the null string as its
only word, then the closure language S* also has the null
string as its only word; that is
if S = { Λ }, then S* = { Λ }
because ΛΛ = Λ.
• Hence, the Kleene closure always produces an infinite
language unless the underlying set is one of the two
cases above.
How to prove a certain word is in the closure
language S*
Lecture 02: Theory of Automata
11
• The Kleene closure of two different sets can end up
being the same language.
• Example: Consider two sets of words
S = { a , b, ab } and T = { a, b, bb }
Then, both S* and T* are languages of all strings of a’s
and b’s since any string of a’s and b’s can be factored
into syllables of (a) or (b), both of which are in S and T.
Kleene Closure of different sets
Lecture 02: Theory of Automata
12
Lecture 02: Theory of Automata
13
Positive Closure
• If we wish to modify the concept of closure to refer only
the concatenation of some (not zero) strings from a set
S, we use the notation + instead of *.
• This “plus operation” is called positive closure.
Example: if ∑ = { x } then ∑+
= { x, xx, xxx, … }
Observe that:
1. If S is a language that does not contain Λ, then S+
is the
language S* without the null word Λ.
2. If S is a language that does contain Λ, then S+
= S*
3. Likewise, if ∑ is an alphabet, then ∑+
is ∑* without the
word Λ.
Lecture 02: Theory of Automata
14
• What happens if we apply the closure operator twice?
– We start with a set of words S and form its closure S*
– We then start with the set S* and try to form its closure, which
we denote as (S*)* or S**
• Theorem 1:
For any set S of strings, we have S* = S**
• Before we prove the theorem, recall from Set Theory
that
– A = B if A is a subset of B and B is a subset of A
– A is a subset of B if for all x in A, x is also in B
S**?
Lecture 02: Theory of Automata
15
Lecture 02: Theory of Automata
16
• Let us first prove that S** is a subset of S*:
Every word in S** is made up of factors from S*. Every
factor from S* is made up of factors from S. Hence, every
word from S** is made up of factors from S. Therefore,
every word in S** is also a word in S*. This implies that S**
is a subset of S*.
• Let us now prove that S* is a subset of S**:
In general, it is true that for any set A, we have A is a
subset of A*, because in A* we can choose as a word any
factor from A. So if we consider A to be our set S* then S*
is a subset of S**
• Together, these two inclusions prove that S* = S**.
Proof of Theorem 1:
Lecture 02: Theory of Automata
17
Defining Languages Continued…
• Recursive definition of languages
The following three steps are used in recursive
definition
1. Some basic words are specified in the
language.
2. Rules for constructing more words are defined
in the language.
3. No strings except those constructed in above,
are allowed to be in the language.
Lecture 02: Theory of Automata
18
Example
• Defining language of EVEN
Step 1:
2 is in EVEN.
Step 2:
If x is in EVEN then x+2 and x-2 are also in
EVEN.
Step 3:
No strings except those constructed in above,
are allowed to be in EVEN.
Lecture 02: Theory of Automata
19
Example
• Defining the language factorial
Step 1:
As 0!=1, so 1 is in factorial.
Step 2:
n!=n*(n-1)! is in factorial.
Step 3:
No strings except those constructed in
above, are allowed to be in factorial.
Lecture 02: Theory of Automata
20
• Defining the language {an
bn
}, n=1,2,3,… , of
strings defined over Σ={a,b}
Step 1:
ab is in {an
bn
}
Step 2:
if x is in {an
bn
}, then axb is in {an
bn
}
Step 3:
No strings except those constructed in
above, are allowed to be in {an
bn
}
Lecture 02: Theory of Automata
21
• Defining the language L, of strings ending in
a , defined over Σ={a,b}
Step 1:
a is in L
Step 2:
if x is in L then s(x) is also in L, where s belongs
to Σ*
Step 3:
No strings except those constructed in
above, are allowed to be in L
Lecture 02: Theory of Automata
22
• Defining the language L, of strings beginning
and ending in same letters , defined over
Σ={a, b}
Step 1:
a and b are in L
Step 2:
(a)s(a) and (b)s(b) are also in L, where s
belongs to Σ*
Step 3:
No strings except those constructed in
above, are allowed to be in L
Lecture 02: Theory of Automata
23
• Defining the language L, of strings
containing exactly aa, defined over Σ={a, b}
Step 1:
aa is in L
Step 2:
s(aa)s is also in L, where s belongs to b*
Step 3:
No strings except those constructed in
above, are allowed to be in L
Lecture 02: Theory of Automata
Theory Of Automata
24
Arithmetic Expressions
• Suppose we ask ourselves what constitutes a
valid arithmetic expression, or AE for short.
• The alphabet for this language is
• Σ = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, +, -, *, /, (, )}
Lecture 02: Theory of Automata
Theory Of Automata
25
Arithmetic Expression AE
• Obviously, the following expressions are not valid:
(3 + 5) + 6) 2(/8 + 9) (3 + (4-)8)
• The first contains unbalanced parentheses; the second
contains the forbidden substring /; the third contains the
forbidden substring -).
• Are there more rules? The subsequences // and */ are
also forbidden.
• Are there still more?
• The most suitable way of defining a valid AE is by using
a recursive definition, rather than a long list of
forbidden substrings.
Lecture 02: Theory of Automata
Theory Of Automata
26
Recursive Definition of AE
• Rule 1: Any number (positive, negative, or zero) is in AE.
• Rule 2: If x is in AE, then so are
(i) (x)
(ii) -x (provided that x does not already start with a minus sign)
• Rule 3: If x and y are in AE, then so are
(i) x + y (if the first symbol in y is not + or -)
(ii) x - y (if the first symbol in y is not + or -)
(iii) x * y
(iv) x / y
(v) x ** y (our notation for exponentiation)
Lecture 02: Theory of Automata
Theory Of Automata
27
• The above definition is the most natural, because it is the method
we use to recognize valid arithmetic expressions in real life.
• For instance, we wish to determine if the following expression is
valid:
(2 + 4) * (7 * (9 - 3)/4)/4 * (2 + 8) – 1
• We do not really scan over the string, looking for forbidden
substrings or count the parentheses.
• We actually imagine the expression in our mind broken down into
components:
Is (2 + 4) OK? Yes
Is (9 - 3) OK? Yes
Is 7 * (9 - 3)/4 OK? Yes, and so on.
Lecture 02: Theory of Automata
Theory Of Automata
28
• Note that the recursive definition of the set AE gives us
the possibility of writing 8/4/2, which is ambiguous,
because it could mean 8/(4/2) = 4 or (8/4)/2 = 1.
• However, the ambiguity of 8/4/2 is a problem of meaning.
There is no doubt that this string is a word in AE, only
doubt about what it means.
• By applying Rule 2, we could always put enough
parentheses to avoid such a confusion.
• The recursive definition of the set AE is useful for proving
many theorems about arithmetic expressions, as we
shall see in the next few slides.
Lecture 02: Theory of Automata
Theorem
• An arithmetic expression cannot contain the
character $.
• Proof
– This character is not part of any number, so it cannot be
introduced into an AE by Rule 1.
– If the character string x does not contain the character $, then
neither do the string (x) and -x. So, the character $ cannot be
introduced into an AE by Rule 2.
– If neither x nor y contains the character $, then neither do any of
the expressions defined in Rule 3.
– Therefore, the character $ can never get into an AE.
Lecture 02: Theory of Automata
Theorem 3 & 4
• No arithmetic expression can begin or end
with the symbol /.
• Proof?
• No arithmetic expression can contain the
substring //.
• Proof?
Lecture 02: Theory of Automata
Theory Of Automata
31
Propositional Calculus
• Propositional calculus (or sentential calculus) is
a branch of symbolic logic that we shall be
interested in.
• The version we define here uses only negation
(¬) and implication (→), together with the phrase
variables.
• The alphabet for this language is
• Σ = {¬, →, (, ), a, b, c, d, …}
• A valid expression in this language is called
WFF (well-form formula).
Lecture 02: Theory of Automata
Theory Of Automata
32
Propositional Calculus
– The rules for forming WFFs are:
• Rule 1: Any single Latin letter is a WFF, for instance a,
b, c, ...
• Rule 2: If p is a WFF, then so are (p) and ¬p.
• Rule 3: If p and q are WFFs, then so is p → q.
– Can you show that p → ((p → p) → q) is a WFF?
– Can you show that the following are NOT WFFs?
• p →
• → p
• p) → p(
Lecture 02: Theory of Automata
• Useful Reading
Third chapter of Daniel I. Cohen book.
33

More Related Content

PPT
Lec 03-Regular Expression.pptLec 01-IntroductionLec 01-IntroductionLec 01-Int...
PPTX
Lesson_3.pptx database management of employee
PPT
Lesson 02.ppt theory of automata including basics of it
PPT
Theory of Automata Lesson 02
PPT
PPT
Lesson 02
PPT
Chapter # 1.ppt cs field using machine management
PPT
Lesson 02.ppt computer science data analysis
Lec 03-Regular Expression.pptLec 01-IntroductionLec 01-IntroductionLec 01-Int...
Lesson_3.pptx database management of employee
Lesson 02.ppt theory of automata including basics of it
Theory of Automata Lesson 02
Lesson 02
Chapter # 1.ppt cs field using machine management
Lesson 02.ppt computer science data analysis

Similar to Lec 02- Recursive Definition.pptLec 01-IntroductionLec 01-IntroductionLec 01-IntroductionLec 01-Introduction (20)

PPT
Lecture 3,4
PPT
Lecture 3,4
PPTX
L_2_apl.pptx
PPTX
Theory of automata and formal language
PPT
PPT
Lesson 03
PPT
Lecture 1,2
PPT
Formal Languages and regular langugaes IN FLAG
PPTX
01 alphabets strings and languages
ODP
Final formal languages
PPT
UNIT III REGULAR GRAMMAR. in automatappt
PDF
01-Introduction&Languages.pdf
PPT
Lec 01-Introduction Lec 01-IntroductionLec 01-Introduction
PDF
Theory of computation
PPTX
Module 1 TOC.pptx
PPT
10651372.ppt
PPT
Lesson 01.ppt theory of automata including basics of it
PPT
Theory of Automata - Power Point Slides Lecture 01).ppt
PPT
Theory of Automata Lesson 01
PPTX
Lecture 3,4
Lecture 3,4
L_2_apl.pptx
Theory of automata and formal language
Lesson 03
Lecture 1,2
Formal Languages and regular langugaes IN FLAG
01 alphabets strings and languages
Final formal languages
UNIT III REGULAR GRAMMAR. in automatappt
01-Introduction&Languages.pdf
Lec 01-Introduction Lec 01-IntroductionLec 01-Introduction
Theory of computation
Module 1 TOC.pptx
10651372.ppt
Lesson 01.ppt theory of automata including basics of it
Theory of Automata - Power Point Slides Lecture 01).ppt
Theory of Automata Lesson 01
Ad

Recently uploaded (20)

PPTX
Safety Seminar civil to be ensured for safe working.
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PPTX
Lecture Notes Electrical Wiring System Components
PDF
Digital Logic Computer Design lecture notes
PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PDF
R24 SURVEYING LAB MANUAL for civil enggi
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PDF
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
PPTX
CH1 Production IntroductoryConcepts.pptx
PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
PPT
Introduction, IoT Design Methodology, Case Study on IoT System for Weather Mo...
PPTX
bas. eng. economics group 4 presentation 1.pptx
PPTX
Geodesy 1.pptx...............................................
PPTX
Sustainable Sites - Green Building Construction
PDF
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
PPTX
Current and future trends in Computer Vision.pptx
PPTX
Artificial Intelligence
PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PPTX
OOP with Java - Java Introduction (Basics)
Safety Seminar civil to be ensured for safe working.
Foundation to blockchain - A guide to Blockchain Tech
CYBER-CRIMES AND SECURITY A guide to understanding
Lecture Notes Electrical Wiring System Components
Digital Logic Computer Design lecture notes
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
R24 SURVEYING LAB MANUAL for civil enggi
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
CH1 Production IntroductoryConcepts.pptx
Automation-in-Manufacturing-Chapter-Introduction.pdf
Introduction, IoT Design Methodology, Case Study on IoT System for Weather Mo...
bas. eng. economics group 4 presentation 1.pptx
Geodesy 1.pptx...............................................
Sustainable Sites - Green Building Construction
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
Current and future trends in Computer Vision.pptx
Artificial Intelligence
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
OOP with Java - Java Introduction (Basics)
Ad

Lec 02- Recursive Definition.pptLec 01-IntroductionLec 01-IntroductionLec 01-IntroductionLec 01-Introduction

  • 1. Lecture 02: Theory of Automata Theory of Automata
  • 2. Lecture 02: Theory of Automata 2 Definition: Palindrome • Let us define a new language called Palindrome over the alphabet ∑ = { a, b } PALINDROME = { Λ, and all strings x such that reverse(x) = x } • If we want to list the elements in PALINDROME, we find PALINDROME = { Λ, a, b, aa, bb, aaa, aba, bab, bbb, aaaa, abba, … }
  • 3. Lecture 02: Theory of Automata 3 • Sometimes two words in PALINDROME when concatenated will produce a word in PALINDROME – abba concatenated with abbaabba gives abbaabbaabba (in PALINDROME) • But more often, the concatenation is not a word in PALINDROME – aa concatenated with aba gives aaaba (NOT in PALINDROME) Palindrome
  • 4. Lecture 02: Theory of Automata 4 Kleene Closure • Definition: Given an alphabet ∑, we define a language in which any string of letters from ∑ is a word, even the null string Λ. We call this language the closure of the alphabet ∑, and denote this language by ∑*. • Examples: If ∑ = { x } then ∑* = { Λ, x, xx, xxx, … } If ∑ = { 0, 1 } then ∑* = { Λ, 0, 1, 00, 01, 10, 11, 000, 001, … } If ∑ = { a, b, c } then ∑* = { Λ, a, b, c, aa, ab, ac, ba, bb, bc, ca, cb, cc, aaa, … }
  • 5. Lecture 02: Theory of Automata 5 • Note that we listed the words in a language in size order (i.e., words of shortest length first), and then listed all the words of the same length alphabetically. • This ordering is called lexicographic order, which we will usually follow. • The star in the closure notation is known as the Kleene star. • We can think of the Kleene star as an operation that makes, out of an alphabet, an infinite language (i.e., infinitely many words, each of finite length). Lexicographic order
  • 6. Lecture 02: Theory of Automata 6 • Let us now generalize the use of the Kleene star oprator to sets of words, not just sets of alphabet letters. • Definition: If S is a set of words, then S* is 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. Kleene Closure
  • 7. Lecture 02: Theory of Automata 7 • Example: If S = { aa, b } then S* = { Λ plus any word composed of factors of aa and b }, or S* = { Λ plus any strings of a’s and b’s in which the a’s occur in even clumps }, or S* = { Λ, b, aa, bb, aab, baa, bbb, aaaa, aabb, baab, bbaa, bbbb, aaaab, aabaa, aabbb, baaaa, baabb, bbaab, bbbaa, bbbbb, … } Note that the string aabaaab is not in S* because it has a clump of a’s of length 3. Kleene Closure
  • 8. Lecture 02: Theory of Automata 8 • Example: Let S = { a, ab }. Then S* = { Λ plus any word composed of factors of a and ab }, or S* = { Λ plus all strings of a’s and b’s except those that start with b and those that contain a double b }, or S* = { Λ, a, aa, ab, aaa, aab, aba, aaaa, aaab, abaa, abab, aaaaa, aaaab, aaaba, aabaa, aabab, abaaa, abaab, ababa, … } • Note that for each word in S*, every b must have an a immediately to its left, so the double b, that is bb, is not possible; neither any string starting with b. Kleene Closure
  • 9. Lecture 02: Theory of Automata 9 • We must show how it can be written as a concatenation of words from the base set S. • In the previous example, to show that abaab is in S*, we can factor it as follows: abaab = (ab)(a)(ab) • These three factors are all in the set S, therefore their concatenation is in S*. • Note that the parentheses, ( ), are used for the sole purpose of demarcating the ends of factors. How to prove a certain word is in the closure language S*
  • 10. Lecture 02: Theory of Automata 10 • Observe that if the alphabet has no letters, then its closure is the language with the null string as its only word; that is if ∑ = ø (the empty set), then ∑* = { Λ } • Also, observe that if the set S has the null string as its only word, then the closure language S* also has the null string as its only word; that is if S = { Λ }, then S* = { Λ } because ΛΛ = Λ. • Hence, the Kleene closure always produces an infinite language unless the underlying set is one of the two cases above. How to prove a certain word is in the closure language S*
  • 11. Lecture 02: Theory of Automata 11 • The Kleene closure of two different sets can end up being the same language. • Example: Consider two sets of words S = { a , b, ab } and T = { a, b, bb } Then, both S* and T* are languages of all strings of a’s and b’s since any string of a’s and b’s can be factored into syllables of (a) or (b), both of which are in S and T. Kleene Closure of different sets
  • 12. Lecture 02: Theory of Automata 12
  • 13. Lecture 02: Theory of Automata 13 Positive Closure • If we wish to modify the concept of closure to refer only the concatenation of some (not zero) strings from a set S, we use the notation + instead of *. • This “plus operation” is called positive closure. Example: if ∑ = { x } then ∑+ = { x, xx, xxx, … } Observe that: 1. If S is a language that does not contain Λ, then S+ is the language S* without the null word Λ. 2. If S is a language that does contain Λ, then S+ = S* 3. Likewise, if ∑ is an alphabet, then ∑+ is ∑* without the word Λ.
  • 14. Lecture 02: Theory of Automata 14 • What happens if we apply the closure operator twice? – We start with a set of words S and form its closure S* – We then start with the set S* and try to form its closure, which we denote as (S*)* or S** • Theorem 1: For any set S of strings, we have S* = S** • Before we prove the theorem, recall from Set Theory that – A = B if A is a subset of B and B is a subset of A – A is a subset of B if for all x in A, x is also in B S**?
  • 15. Lecture 02: Theory of Automata 15
  • 16. Lecture 02: Theory of Automata 16 • Let us first prove that S** is a subset of S*: Every word in S** is made up of factors from S*. Every factor from S* is made up of factors from S. Hence, every word from S** is made up of factors from S. Therefore, every word in S** is also a word in S*. This implies that S** is a subset of S*. • Let us now prove that S* is a subset of S**: In general, it is true that for any set A, we have A is a subset of A*, because in A* we can choose as a word any factor from A. So if we consider A to be our set S* then S* is a subset of S** • Together, these two inclusions prove that S* = S**. Proof of Theorem 1:
  • 17. Lecture 02: Theory of Automata 17 Defining Languages Continued… • Recursive definition of languages The following three steps are used in recursive definition 1. Some basic words are specified in the language. 2. Rules for constructing more words are defined in the language. 3. No strings except those constructed in above, are allowed to be in the language.
  • 18. Lecture 02: Theory of Automata 18 Example • Defining language of EVEN Step 1: 2 is in EVEN. Step 2: If x is in EVEN then x+2 and x-2 are also in EVEN. Step 3: No strings except those constructed in above, are allowed to be in EVEN.
  • 19. Lecture 02: Theory of Automata 19 Example • Defining the language factorial Step 1: As 0!=1, so 1 is in factorial. Step 2: n!=n*(n-1)! is in factorial. Step 3: No strings except those constructed in above, are allowed to be in factorial.
  • 20. Lecture 02: Theory of Automata 20 • Defining the language {an bn }, n=1,2,3,… , of strings defined over Σ={a,b} Step 1: ab is in {an bn } Step 2: if x is in {an bn }, then axb is in {an bn } Step 3: No strings except those constructed in above, are allowed to be in {an bn }
  • 21. Lecture 02: Theory of Automata 21 • Defining the language L, of strings ending in a , defined over Σ={a,b} Step 1: a is in L Step 2: if x is in L then s(x) is also in L, where s belongs to Σ* Step 3: No strings except those constructed in above, are allowed to be in L
  • 22. Lecture 02: Theory of Automata 22 • Defining the language L, of strings beginning and ending in same letters , defined over Σ={a, b} Step 1: a and b are in L Step 2: (a)s(a) and (b)s(b) are also in L, where s belongs to Σ* Step 3: No strings except those constructed in above, are allowed to be in L
  • 23. Lecture 02: Theory of Automata 23 • Defining the language L, of strings containing exactly aa, defined over Σ={a, b} Step 1: aa is in L Step 2: s(aa)s is also in L, where s belongs to b* Step 3: No strings except those constructed in above, are allowed to be in L
  • 24. Lecture 02: Theory of Automata Theory Of Automata 24 Arithmetic Expressions • Suppose we ask ourselves what constitutes a valid arithmetic expression, or AE for short. • The alphabet for this language is • Σ = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, +, -, *, /, (, )}
  • 25. Lecture 02: Theory of Automata Theory Of Automata 25 Arithmetic Expression AE • Obviously, the following expressions are not valid: (3 + 5) + 6) 2(/8 + 9) (3 + (4-)8) • The first contains unbalanced parentheses; the second contains the forbidden substring /; the third contains the forbidden substring -). • Are there more rules? The subsequences // and */ are also forbidden. • Are there still more? • The most suitable way of defining a valid AE is by using a recursive definition, rather than a long list of forbidden substrings.
  • 26. Lecture 02: Theory of Automata Theory Of Automata 26 Recursive Definition of AE • Rule 1: Any number (positive, negative, or zero) is in AE. • Rule 2: If x is in AE, then so are (i) (x) (ii) -x (provided that x does not already start with a minus sign) • Rule 3: If x and y are in AE, then so are (i) x + y (if the first symbol in y is not + or -) (ii) x - y (if the first symbol in y is not + or -) (iii) x * y (iv) x / y (v) x ** y (our notation for exponentiation)
  • 27. Lecture 02: Theory of Automata Theory Of Automata 27 • The above definition is the most natural, because it is the method we use to recognize valid arithmetic expressions in real life. • For instance, we wish to determine if the following expression is valid: (2 + 4) * (7 * (9 - 3)/4)/4 * (2 + 8) – 1 • We do not really scan over the string, looking for forbidden substrings or count the parentheses. • We actually imagine the expression in our mind broken down into components: Is (2 + 4) OK? Yes Is (9 - 3) OK? Yes Is 7 * (9 - 3)/4 OK? Yes, and so on.
  • 28. Lecture 02: Theory of Automata Theory Of Automata 28 • Note that the recursive definition of the set AE gives us the possibility of writing 8/4/2, which is ambiguous, because it could mean 8/(4/2) = 4 or (8/4)/2 = 1. • However, the ambiguity of 8/4/2 is a problem of meaning. There is no doubt that this string is a word in AE, only doubt about what it means. • By applying Rule 2, we could always put enough parentheses to avoid such a confusion. • The recursive definition of the set AE is useful for proving many theorems about arithmetic expressions, as we shall see in the next few slides.
  • 29. Lecture 02: Theory of Automata Theorem • An arithmetic expression cannot contain the character $. • Proof – This character is not part of any number, so it cannot be introduced into an AE by Rule 1. – If the character string x does not contain the character $, then neither do the string (x) and -x. So, the character $ cannot be introduced into an AE by Rule 2. – If neither x nor y contains the character $, then neither do any of the expressions defined in Rule 3. – Therefore, the character $ can never get into an AE.
  • 30. Lecture 02: Theory of Automata Theorem 3 & 4 • No arithmetic expression can begin or end with the symbol /. • Proof? • No arithmetic expression can contain the substring //. • Proof?
  • 31. Lecture 02: Theory of Automata Theory Of Automata 31 Propositional Calculus • Propositional calculus (or sentential calculus) is a branch of symbolic logic that we shall be interested in. • The version we define here uses only negation (¬) and implication (→), together with the phrase variables. • The alphabet for this language is • Σ = {¬, →, (, ), a, b, c, d, …} • A valid expression in this language is called WFF (well-form formula).
  • 32. Lecture 02: Theory of Automata Theory Of Automata 32 Propositional Calculus – The rules for forming WFFs are: • Rule 1: Any single Latin letter is a WFF, for instance a, b, c, ... • Rule 2: If p is a WFF, then so are (p) and ¬p. • Rule 3: If p and q are WFFs, then so is p → q. – Can you show that p → ((p → p) → q) is a WFF? – Can you show that the following are NOT WFFs? • p → • → p • p) → p(
  • 33. Lecture 02: Theory of Automata • Useful Reading Third chapter of Daniel I. Cohen book. 33