Docsity

Regular Languages and Regular Expressions, Lecture notes of Theory of Formal Languages for Automata

Partial preview of the text

Download Regular Languages and Regular Expressions and more Lecture notes Theory of Formal Languages for Automata in PDF only on Docsity!

Regular Languages and

Regular Expressions

Regular Expressions

  • (^) Regular expressions: one way of describing regular languages is via regular expression.
  • (^) It is a combination of strings of symbols, parentheses, and the operators +,. , and *
  • (^) + for union,. For concatenation, and * for star-closure Example: describes the language ( abc ) *  a , bc  * , a , bc , aa , abc , bca , aaaa , bcbc , aabc , bcaa ,...

Examples A regular expression:  abc  * ( c Æ) Not a regular expression:^ ^ a ^ b 

Languages of Regular Expressions : language of regular expression Example Lrr L  ( abc )*  , a , bc , aa , abc , bca ,...

Definition (continued) For regular expressions 1 and r 2 r       1 2 1 2 L rrL rL r       1 2 1 2 L rrL r L r  *    * 1 1 L rL r      1 1 L rL r

Example Regular expression: ab   a * L   ab   a *  L   ab  La *  LabLa *  La   Lb   La  *   a   b     a   *   a , b   , a , aa , aaa ,...   a , aa , aaa ,..., b , ba , baa ,...

Example Regular expression r^ ^ aa ^ *^ bb ^ * b   { : , 0 } 2 2 L ra b b n mn m

Example: what is the regular Expression? r ( 0  1 )* 00 ( 0  1 ) * L ( r )= { all strings with at least two consecutive 0 } Every string in L(r) must contains 00 somewhere, but what comes before or what comes after is completely arbitrary.

Example Cont.

  1. The strings ending with 0 or
  2. consisting of all 1s are unaccounted for r= (1011)(0+λ) + 1(0+ λ) If we see L as the repetition of the strings 1 and 01, the shorter expression r=(1+01)*(0+ λ)

Equivalent Regular Expressions Definition: Regular expressions and are equivalent if 1 r 2 r ( ) ( ) 1 2 L rL r

Regular Expressions

and

Regular Languages

Theorem Languages Generated by Regular Expressions Regular Languages

Theorem - Part 2 Languages Generated by Regular Expressions Regular Languages  L r L^ ( r )  L

  1. For any regular language there is a regular expression with

Proof - Part 1 r L ( r )

  1. For any regular expression the language is regular Proof by induction on the size of (^) r