0% found this document useful (0 votes)
22 views

40-Multitrack TM, Pattern Matching-02-05-2024

Multitrack turing machine

Uploaded by

jesujoelv8
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

40-Multitrack TM, Pattern Matching-02-05-2024

Multitrack turing machine

Uploaded by

jesujoelv8
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

BCSE304L

Theory of Computation
Lecture 32
Dr. Saritha Murali
(SCOPE, VIT Vellore)
02-05-2024
Multi-track Turing machine

• Multi-track Turing machines, a specific type of Multi-tape Turing


machine, contain multiple tracks but just one tape head reads and
writes on all tracks.

• A single tape head reads n symbols from n tracks at one step.

• It accepts recursively enumerable languages like a normal single-track


single-tape Turing Machine accepts.
Representation
A Multi-track Turing machine can be formally described as a 6-tuple (Q, X, ∑,
δ, q0, F) where −
Q is a finite set of states
X is the tape alphabet
∑ is the input alphabet
δ is a relation on states and symbols where
δ(Qi, [a1, a2, a3,....]) = (Qj, [b1, b2, b3,....], Left_shift or Right_shift)
q0 is the initial state
F is the set of final states
Note − For every single-track Turing Machine S, there is an equivalent multi-
track Turing Machine M such that L(S) = L(M).
Problems
Pattern matching in regular expressions
• Repeaters : * , + and { } : These symbols act as repeaters and tell the
computer that the preceding character is to be used for more than just one
time.
• The asterisk symbol ( * ): It tells the computer to match the preceding
character (or set of characters) for 0 or more times (upto infinite).
• Example : The regular expression ab*c will give ac, abc, abbc, abbbc….and
so on
• The Plus symbol ( + ): It tells the computer to repeat the preceding
character (or set of characters) for atleast one or more times(upto infinite).
• Example : The regular expression ab+c will give abc, abbc, abbc, … and so
on.
• The curly braces {…}: It tells the computer to repeat the preceding
character (or set of characters) for as many times as the value inside
this bracket.
• Example :
• {2} means that the preceding character is to be repeated 2 times
• {min,} means the preceding character is matches min or more times.
• {min,max} means that the preceding character is repeated at least
min & at most max times.
• Wildcard – ( . ) The dot symbol can take place of any other symbol, that is
why it is called the wildcard character.
• Example : The Regular expression .* will tell the computer that any
character can be used any number of times.

• Optional character – ( ? ) This symbol tells the computer that the


preceding character may or may not be present in the string to be
matched.
• Example : We may write the format for document file as – “docx?” The ‘?’
tells the computer that x may or may not be present in the name of file
format.
• The caret ( ^ ) symbol: Setting position for match :tells the computer
that the match must start at the beginning of the string or line.
• Example : ^\d{3} will match with patterns like "901" in "901-333-".

• The dollar ( $ ) symbol It tells the computer that the match must
occur at the end of the string
• Example : -\d{3}$ will match with patterns like "-333" in "-901-333".
• Character Classes A character class matches any one of a set of
characters. It is used to match the most basic element of a language
like a letter, a digit, space, a symbol etc. /s : matches any whitespace
characters such as space and tab /S : matches any non-whitespace
characters /d : matches any digit character /D : matches any non-digit
characters /w : matches any word character (basically alpha-
numeric) /W : matches any non-word character /b : matches any
word boundary (this would include spaces, dashes, commas, semi-
colons, etc)
• [set_of_characters] – Matches any single character in
set_of_characters. By default, the match is case-sensitive.
• Example : [abc] will match characters a,b and c in any string.

• [first-last] – Character range: Matches any single character in the


range from first to last.
• Example : [a-zA-z] will match any character from a to z or A to Z.
• The Escape Symbol : \ If you want to match for the actual ‘+’, ‘.’ etc
characters, add a backslash( \ ) before that character. This will tell the
computer to treat the following character as a search character and
consider it for matching pattern.
• Example : \d+[\+-x\*]\d+ will match patterns like "2+2" and "3*9" in
"(2+2) * 3*9".
• Grouping Characters ( ) A set of different symbols of a regular
expression can be grouped together to act as a single unit and behave
as a block, for this, you need to wrap the regular expression in the
parenthesis( ).
• Example : ([A-Z]\w+) contains two different elements of the regular
expression combined together. This expression will match any pattern
containing uppercase letter followed by any character.
• Vertical Bar ( | ) : Matches any one element separated by the vertical
bar (|) character.
• Example : th(e|is|at) will match words - the, this and that.
Pattern matching in regular expressions
• email id : ^[a-zA-Z0-9.]+@[a-zA-Z0-9]+\.(com|edu|org|net|in)$

• Mobile number

You might also like