Regular Expressions (REs)
Regular Expressions (REs) – p.1/37
Regular Expressions (REs) Regular Expressions (REs) p.1/37 - - PowerPoint PPT Presentation
Regular Expressions (REs) Regular Expressions (REs) p.1/37 Expressions In arithmetic: Regular Expressions (REs) p.2/37 Expressions In arithmetic: 1. expressions are constructed from numbers and variables using arithmetic
Regular Expressions (REs) – p.1/37
Regular Expressions (REs) – p.2/37
using arithmetic operations and parantheses
Regular Expressions (REs) – p.2/37
using arithmetic operations and parantheses
Regular Expressions (REs) – p.2/37
using arithmetic operations and parantheses
Regular Expressions (REs) – p.2/37
using arithmetic operations and parantheses
Regular Expressions (REs) – p.2/37
using arithmetic operations and parantheses
using regular operations and parentheses
Regular Expressions (REs) – p.2/37
using arithmetic operations and parantheses
using regular operations and parentheses
languages
Regular Expressions (REs) – p.2/37
using arithmetic operations and parantheses
using regular operations and parentheses
languages
Regular Expressions (REs) – p.2/37
Regular Expressions (REs) – p.3/37
Regular Expressions (REs) – p.3/37
Regular Expressions (REs) – p.3/37
Regular Expressions (REs) – p.4/37
Regular Expressions (REs) – p.4/37
and
✄represents the language
✁ ✄ ✂Regular Expressions (REs) – p.4/37
and
✄represents the language
✁ ✄ ✂following their set-theory definitions.
Regular Expressions (REs) – p.4/37
and
✄represents the language
✁ ✄ ✂following their set-theory definitions.
represents the language
✁ ☎✄ ✄ ✂,
represents the language
✁✞✝ ✄and
represents the language
✁Regular Expressions (REs) – p.4/37
and
✄represents the language
✁ ✄ ✂following their set-theory definitions.
represents the language
✁ ☎✄ ✄ ✂,
represents the language
✁✞✝ ✄and
represents the language
✁Regular Expressions (REs) – p.4/37
Regular Expressions (REs) – p.5/37
Regular Expressions (REs) – p.5/37
Regular Expressions (REs) – p.5/37
Regular Expressions (REs) – p.5/37
Regular Expressions (REs) – p.6/37
Regular Expressions (REs) – p.6/37
Regular Expressions (REs) – p.7/37
Regular Expressions (REs) – p.7/37
Regular Expressions (REs) – p.7/37
Regular Expressions (REs) – p.7/37
Regular Expressions (REs) – p.8/37
Recursion basis:
Regular Expressions (REs) – p.8/37
Recursion basis:
,
Regular Expressions (REs) – p.8/37
Recursion basis:
,
2.
✝is a RE describing the language
✄Regular Expressions (REs) – p.8/37
Recursion basis:
,
2.
✝is a RE describing the language
✄3.
Regular Expressions (REs) – p.8/37
Regular Expressions (REs) – p.9/37
1.
is a RE evaluating to
✄Regular Expressions (REs) – p.9/37
1.
is a RE evaluating to
✄2.
is a RE evaluating to
✄Regular Expressions (REs) – p.9/37
1.
is a RE evaluating to
✄2.
is a RE evaluating to
✄3.
is a RE evaluating to
✁✁ ✂ ✄ ✄and
✄.
Regular Expressions (REs) – p.9/37
Regular Expressions (REs) – p.10/37
Regular Expressions (REs) – p.11/37
1.
✝represents the language containing just the empty string
Regular Expressions (REs) – p.11/37
1.
✝represents the language containing just the empty string 2.
Regular Expressions (REs) – p.11/37
1.
✝represents the language containing just the empty string 2.
1.
,
Regular Expressions (REs) – p.12/37
1.
,
✄Regular Expressions (REs) – p.12/37
1.
,
✄2.
✂ ✆ ✄ ✂ ✆,
Regular Expressions (REs) – p.12/37
1.
,
✄2.
✂ ✆ ✄ ✂ ✆,
✄Regular Expressions (REs) – p.12/37
1.
,
✄2.
✂ ✆ ✄ ✂ ✆,
✄3.
✂ ✆,
Regular Expressions (REs) – p.12/37
1.
,
✄2.
✂ ✆ ✄ ✂ ✆,
✄3.
✂ ✆,
✄as a substring
✂Regular Expressions (REs) – p.12/37
1.
,
✄2.
✂ ✆ ✄ ✂ ✆,
✄3.
✂ ✆,
✄as a substring
✂4.
,
Regular Expressions (REs) – p.12/37
1.
,
✄2.
✂ ✆ ✄ ✂ ✆,
✄3.
✂ ✆,
✄as a substring
✂4.
,
✄Regular Expressions (REs) – p.12/37
1.
,
✄2.
✂ ✆ ✄ ✂ ✆,
✄3.
✂ ✆,
✄as a substring
✂4.
,
✄5.
,
Regular Expressions (REs) – p.12/37
1.
,
✄2.
✂ ✆ ✄ ✂ ✆,
✄3.
✂ ✆,
✄as a substring
✂4.
,
✄5.
,
✄the length of
Regular Expressions (REs) – p.12/37
1.
,
✄2.
✂ ✆ ✄ ✂ ✆,
✄3.
✂ ✆,
✄as a substring
✂4.
,
✄5.
,
✄the length of
6.
,
Regular Expressions (REs) – p.12/37
1.
,
✄2.
✂ ✆ ✄ ✂ ✆,
✄3.
✂ ✆,
✄as a substring
✂4.
,
✄5.
,
✄the length of
6.
,
✄Regular Expressions (REs) – p.12/37
1.
,
✄2.
✂ ✆ ✄ ✂ ✆,
✄3.
✂ ✆,
✄as a substring
✂4.
,
✄5.
,
✄the length of
6.
,
✄7.
,
Regular Expressions (REs) – p.12/37
1.
,
✄2.
✂ ✆ ✄ ✂ ✆,
✄3.
✂ ✆,
✄as a substring
✂4.
,
✄5.
,
✄the length of
6.
,
✄7.
,
✄ends with the same symbol
✂Regular Expressions (REs) – p.12/37
1.
,
✄2.
✂ ✆ ✄ ✂ ✆,
✄3.
✂ ✆,
✄as a substring
✂4.
,
✄5.
,
✄the length of
6.
,
✄7.
,
✄ends with the same symbol
✂8.
,
Regular Expressions (REs) – p.12/37
1.
,
✄2.
✂ ✆ ✄ ✂ ✆,
✄3.
✂ ✆,
✄as a substring
✂4.
,
✄5.
,
✄the length of
6.
,
✄7.
,
✄ends with the same symbol
✂8.
,
✄Regular Expressions (REs) – p.12/37
1.
,
✄2.
✂ ✆ ✄ ✂ ✆,
✄3.
✂ ✆,
✄as a substring
✂4.
,
✄5.
,
✄the length of
6.
,
✄7.
,
✄ends with the same symbol
✂8.
,
✄9.
,
Regular Expressions (REs) – p.12/37
1.
,
✄2.
✂ ✆ ✄ ✂ ✆,
✄3.
✂ ✆,
✄as a substring
✂4.
,
✄5.
,
✄the length of
6.
,
✄7.
,
✄ends with the same symbol
✂8.
,
✄9.
,
✄Regular Expressions (REs) – p.12/37
Regular Expressions (REs) – p.13/37
Regular Expressions (REs) – p.13/37
Regular Expressions (REs) – p.14/37
Regular Expressions (REs) – p.14/37
Regular Expressions (REs) – p.14/37
Regular Expressions (REs) – p.15/37
Regular Expressions (REs) – p.15/37
Regular Expressions (REs) – p.16/37
Regular Expressions (REs) – p.16/37
Example: numerical constants can be described by:
✁ ☎ ✄ ✆ ✄ ✝ ✂where
Regular Expressions (REs) – p.16/37
Example: numerical constants can be described by:
✁ ☎ ✄ ✆ ✄ ✝ ✂where
Regular Expressions (REs) – p.16/37
Regular Expressions (REs) – p.17/37
Regular Expressions (REs) – p.18/37
Regular Expressions (REs) – p.18/37
Regular Expressions (REs) – p.19/37
Regular Expressions (REs) – p.19/37
i.e., there is a finite automaton that recognizes it.
Regular Expressions (REs) – p.19/37
i.e., there is a finite automaton that recognizes it.
RE that specifies it
Regular Expressions (REs) – p.19/37
Regular Expressions (REs) – p.20/37
Regular Expressions (REs) – p.20/37
Regular Expressions (REs) – p.20/37
Regular Expressions (REs) – p.20/37
Regular Expressions (REs) – p.21/37
recognizing
✁Regular Expressions (REs) – p.22/37
recognizing
✁Regular Expressions (REs) – p.22/37
recognizing
✁ ✝ ✂Regular Expressions (REs) – p.24/37
recognizing
Regular Expressions (REs) – p.27/37
Regular Expressions (REs) – p.28/37
Note: in view with the inductive nature of
Regular Expressions (REs) – p.28/37
Note: in view with the inductive nature of
1.
☎ ✁ ☎is an NFA recognizing
✄Regular Expressions (REs) – p.28/37
Note: in view with the inductive nature of
1.
☎ ✁ ☎is an NFA recognizing
✄2.
☎ ✂ ☎is an NFA recognizing
✄Regular Expressions (REs) – p.28/37
Note: in view with the inductive nature of
1.
☎ ✁ ☎is an NFA recognizing
✄2.
☎ ✂ ☎is an NFA recognizing
✄Regular Expressions (REs) – p.28/37
to recognize
✄Regular Expressions (REs) – p.29/37
1.
: That is, the states of
☎are all states on
☎ ✁and
☎ ✂with the addition of a new state
✄ ✄Regular Expressions (REs) – p.30/37
1.
: That is, the states of
☎are all states on
☎ ✁and
☎ ✂with the addition of a new state
✄ ✄is
✄ ✄Regular Expressions (REs) – p.30/37
1.
: That is, the states of
☎are all states on
☎ ✁and
☎ ✂with the addition of a new state
✄ ✄is
✄ ✄are
✂ ☎ ✂ ✁ ✁ ✂ ✂: That is, the accept states
are all the accept states of
☎ ✁and
☎ ✂Regular Expressions (REs) – p.30/37
1.
: That is, the states of
☎are all states on
☎ ✁and
☎ ✂with the addition of a new state
✄ ✄is
✄ ✄are
✂ ☎ ✂ ✁ ✁ ✂ ✂: That is, the accept states
are all the accept states of
☎ ✁and
☎ ✂so that for any
✄ ✁:
✁if
✄ ✁if
✄ ✁if
✄ ☎ ✄ ✄and
if
✄ ☎ ✄ ✄and
.
Regular Expressions (REs) – p.30/37
Regular Expressions (REs) – p.31/37
Note: in view with the inductive nature of
Regular Expressions (REs) – p.31/37
Note: in view with the inductive nature of
1.
☎ ✁ ☎is an NFA recognizing
✄Regular Expressions (REs) – p.31/37
Note: in view with the inductive nature of
1.
☎ ✁ ☎is an NFA recognizing
✄2.
☎ ✂ ☎is an NFA recognizing
✄.
Regular Expressions (REs) – p.31/37
to recognize
✄Regular Expressions (REs) – p.32/37
1.
. The states of
☎are all states of
☎ ✁and
☎ ✂Regular Expressions (REs) – p.33/37
1.
. The states of
☎are all states of
☎ ✁and
☎ ✂Regular Expressions (REs) – p.33/37
1.
. The states of
☎are all states of
☎ ✁and
☎ ✂Regular Expressions (REs) – p.33/37
1.
. The states of
☎are all states of
☎ ✁and
☎ ✂so that for any
✄ ✁if
✄ ✁and
✄ ✠ ✁ ✂ ✁ ✁ ✁if
✄ ✁ ✂ ✁and
if
✄ ✁ ✂ ✁and
if
✄ ✁.
Regular Expressions (REs) – p.33/37
Regular Expressions (REs) – p.34/37
Note: in view with the inductive nature of
Regular Expressions (REs) – p.34/37
Note: in view with the inductive nature of
1.
☎ ✁ ☎is an NFA recognizing
✄Regular Expressions (REs) – p.34/37
Note: in view with the inductive nature of
1.
☎ ✁ ☎is an NFA recognizing
✄Regular Expressions (REs) – p.34/37
Regular Expressions (REs) – p.35/37
1.
; that is, states of
☎are the states of
☎ ✁plus a new state
✄ ✄Regular Expressions (REs) – p.36/37
1.
; that is, states of
☎are the states of
☎ ✁plus a new state
✄ ✄is
✄ ✄Regular Expressions (REs) – p.36/37
1.
; that is, states of
☎are the states of
☎ ✁plus a new state
✄ ✄is
✄ ✄3.
✂ ☎ ✁ ✄ ✄ ✂ ✁ ✂ ✁; that is, the accept states of
☎are the accept states of
☎ ✁plus the new start state
Regular Expressions (REs) – p.36/37
1.
; that is, states of
☎are the states of
☎ ✁plus a new state
✄ ✄is
✄ ✄3.
✂ ☎ ✁ ✄ ✄ ✂ ✁ ✂ ✁; that is, the accept states of
☎are the accept states of
☎ ✁plus the new start state
so that for any
✄ ✁if
✄ ✁and
✄ ✠ ✁ ✂ ✁ ✁ ✁if
✄ ✁ ✂ ✁and
if
✄ ✁ ✂ ✁and
if
✄ ☎ ✄ ✄and
if
✄ ☎ ✄ ✄and
.
Regular Expressions (REs) – p.36/37