Formal Methods: Finite State Machine - Regular Expressions
Formal Methods: Finite State Machine - Regular Expressions
METHODS
Lecture 7: Finite state machine –Regular Expressions
LECTURER: QURATULAIN
DEPARTMENT OF INFORMATION TECHNOLOGY
GOVERNMENT COLLEGE UNIVERSITY FAISALABAD
FINITE STATE MACHINE
MODELS
If Σ is an alphabet (a set of symbols), then the Kleene star of Σ , denoted Σ∗ , is the set
of all strings of finite length consisting of symbols in Σ , including the empty string λ
REGULAR EXPRESSIONS
• An expression is regular if:
• ɸ is a regular expression for regular language ɸ.
• ɛ is a regular expression for regular language {ɛ}.
• If a ∈ Σ (Σ represents the input alphabet), a is regular expression with language
{a}.
• If a and b are regular expression, a + b is also a regular expression with
language {a,b}.
• If a and b are regular expression, ab (concatenation of a and b) is also regular.
• If a is regular expression, a* (0 or more times a) is also regular.
REGULAR EXPRESSIONS
Example 1:
Language L of words defined over ∑= {a,b) starting with a
∑= {a,b)
∑={ a,ab, abb, abbb,abbba,abbbb, aa,aaa, ……….}
RE= (ab*)
“All words of the string form one “A” followed by some numbers of b‟s (may be
no b at all)
REGULAR EXPRESSIONS
Example 2:
Language L of words defined over ∑= {a,b) starting with “a”, following some b and
ends with “a”
∑= {a,b)
∑={ a,aba, abba, abbba,abbba,abbbba, aa,aaba, ……….}
RE= (ab*a)
“All words of the string form one “A” followed by some numbers of b‟s (may be
no b at all) and ends with a
REGULAR EXPRESSIONS
Example 2:
Language L of words defined over ∑= {a,b,c) starting with “a” or “c” then followed
some “b”.
∑= {a,b,c)
∑={ a,c, ab, cb,abb, cbb, abbbb, cbbb, ……….}
RE= ((a+c)b*)
“All words of the string form one “a” OR “c” followed by some numbers of b‟s
(may be no b at all)
REGULAR EXPRESSION
REGULAR LANGUAGES
Example 2 − For a regular expression (a+b), we Example 3 − For a regular expression (a+b)*, we
can construct the following FA − can construct the following FA −