Chapter1Section3_F11

Chapter1Section3_F11 - 91.304 Foundations of (Theoretical)...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon
91.304 Foundations of (Theoretical) Computer Science Chapter 1 Lecture Notes (Section 1.3: Regular Expressions) David Martin dm@cs.uml.edu with some modifications by Prof. Karen Daniels, Fall 2011 This work is licensed under the Creative Commons Attribution-ShareAlike License. To view a copy of this license, visit http://creativecommons.org/licenses/by- 1 sa/2.0/ or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Regular expressions ou might be familiar with these ± You might be familiar with these. ± Example: "^int .*\(.*\);" is a (flex format) gular expression that appears to match C regular expression that appears to match C function prototypes that return ints. ± In our treatment, a regular expression is a program that generates a language of matching strings when you "run it“. ± We will use a very compact definition that simplifies things later. 2 Flex = Fast Lexical Analyzer Generator
Background image of page 2
Regular expressions efinition et e an alphabet not containing any of ± Definition. Let Σ be an alphabet not containing any of the special characters in this list: ε ) ( · We define the syntax of the (programming) language REX( Σ ), abbreviated as REX, inductively: ² Base cases 1. For all a Σ , a REX. In other words, each single character from Σ is a regular expression all by itself. EX In other words the literal symbol a regular 2. ε REX. In other words, the literal symbol ε is a regular expression. In this context it is not the empty string but rather the single-character name for the empty string. 3. ∅∈ REX. Similarly, the literal symbol is a regular expression. Notes : -REX is not defined in our textbook, but is helpful in continuing to build our iagram of languages 3 diagram of languages. -In our textbook, a represents language {a}, ε represents language { ε }.
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Regular expressions ± Definition continued ² Induction cases or all EX 4. For all r 1 , r 2 REX, ( r 1 r 2 ) REX also literal symbols variables 5. For all r 1 , r 2 REX, ( r 1 · r 2 ) REX also 4 Note: Later we remove dot, which is denoted by empty circle in textbook (later also removed).
Background image of page 4
Regular expressions efinition continued ± Definition continued ² Induction cases continued 6. For all r REX, ( r * ) REX also ± Examples over Σ ={0,1} nd and 1 and ² ε and 0 and 1 and ² (((1 · 0) · ( ε ∪∅ )) * ) ot regular expression ² εε is not a regular expression ± Remember, in the context of regular expressions, ε and are ordinary characters 5 Note: Textbook also defines R + = R R *, where R is a regular expression.
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Semantics of regular expressions efinition e define the meaning of the ± Definition. We define the meaning of the language REX( Σ ) inductively using the L() operator so that L(r) denotes the language generated by r as follows: ² Base cases 1. For all a Σ , L(a) = { a }. A single-character regular expression generates the corresponding single-character string.
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/13/2012 for the course CS 91.304 taught by Professor Staff during the Fall '11 term at UMass Lowell.

Page1 / 36

Chapter1Section3_F11 - 91.304 Foundations of (Theoretical)...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online