Docsity

Operations on Languages and Regular Expressions, Lecture notes of Theory of Computation

Partial preview of the text

Download Operations on Languages and Regular Expressions and more Lecture notes Theory of Computation in PDF only on Docsity!

Regular Expressions

CS 373: Theory of Computation

Gul Agha Mahesh Viswanathan

University of Illinois, Urbana-Champaign

Fall 2010

Regular Expressions

Operations on Languages

Recall: A language is a set of strings

Regular Expressions

Operations on Languages

Recall: A language is a set of strings We can consider new languages derived from operations on given languages e.g., L 1 ∪ L 2 ,

Regular Expressions

Operations on Languages

Recall: A language is a set of strings We can consider new languages derived from operations on given languages e.g., L 1 ∪ L 2 , L 1 ∩ L 2 ,

Regular Expressions

Operations on Languages

Recall: A language is a set of strings We can consider new languages derived from operations on given languages e.g., L 1 ∪ L 2 , L 1 ∩ L 2 , 12 L,... A simple but powerful collection of operations:

Regular Expressions

Operations on Languages

Recall: A language is a set of strings We can consider new languages derived from operations on given languages e.g., L 1 ∪ L 2 , L 1 ∩ L 2 , 12 L,... A simple but powerful collection of operations: Union, Concatenation and Kleene Closure

Regular Expressions

Concatenation of Languages

Definition Given languages L 1 and L 2 , we define their concatenation to be the language L 1 ◦ L 2 = {xy | x ∈ L 1 , y ∈ L 2 }

Example L 1 = {hello} and L 2 = {world} then L 1 ◦ L 2 =

Regular Expressions

Concatenation of Languages

Definition Given languages L 1 and L 2 , we define their concatenation to be the language L 1 ◦ L 2 = {xy | x ∈ L 1 , y ∈ L 2 }

Example L 1 = {hello} and L 2 = {world} then L 1 ◦ L 2 = {helloworld}

Regular Expressions

Concatenation of Languages

Definition Given languages L 1 and L 2 , we define their concatenation to be the language L 1 ◦ L 2 = {xy | x ∈ L 1 , y ∈ L 2 }

Example L 1 = {hello} and L 2 = {world} then L 1 ◦ L 2 = {helloworld} L 1 = { 00 , 10 }; L 2 = { 0 , 1 }. L 1 ◦ L 2 = { 000 , 001 , 100 , 101 }

Regular Expressions

Concatenation of Languages

Definition Given languages L 1 and L 2 , we define their concatenation to be the language L 1 ◦ L 2 = {xy | x ∈ L 1 , y ∈ L 2 }

Example L 1 = {hello} and L 2 = {world} then L 1 ◦ L 2 = {helloworld} L 1 = { 00 , 10 }; L 2 = { 0 , 1 }. L 1 ◦ L 2 = { 000 , 001 , 100 , 101 } L 1 = set of strings ending in 0; L 2 = set of strings beginning with 01. L 1 ◦ L 2 =

Regular Expressions

Concatenation of Languages

Definition Given languages L 1 and L 2 , we define their concatenation to be the language L 1 ◦ L 2 = {xy | x ∈ L 1 , y ∈ L 2 }

Example L 1 = {hello} and L 2 = {world} then L 1 ◦ L 2 = {helloworld} L 1 = { 00 , 10 }; L 2 = { 0 , 1 }. L 1 ◦ L 2 = { 000 , 001 , 100 , 101 } L 1 = set of strings ending in 0; L 2 = set of strings beginning with 01. L 1 ◦ L 2 = set of strings containing 001 as a substring L ◦ {} =

Regular Expressions

Concatenation of Languages

Definition Given languages L 1 and L 2 , we define their concatenation to be the language L 1 ◦ L 2 = {xy | x ∈ L 1 , y ∈ L 2 }

Example L 1 = {hello} and L 2 = {world} then L 1 ◦ L 2 = {helloworld} L 1 = { 00 , 10 }; L 2 = { 0 , 1 }. L 1 ◦ L 2 = { 000 , 001 , 100 , 101 } L 1 = set of strings ending in 0; L 2 = set of strings beginning with 01. L 1 ◦ L 2 = set of strings containing 001 as a substring L ◦ {} = L.

Regular Expressions

Concatenation of Languages

Definition Given languages L 1 and L 2 , we define their concatenation to be the language L 1 ◦ L 2 = {xy | x ∈ L 1 , y ∈ L 2 }

Example L 1 = {hello} and L 2 = {world} then L 1 ◦ L 2 = {helloworld} L 1 = { 00 , 10 }; L 2 = { 0 , 1 }. L 1 ◦ L 2 = { 000 , 001 , 100 , 101 } L 1 = set of strings ending in 0; L 2 = set of strings beginning with 01. L 1 ◦ L 2 = set of strings containing 001 as a substring L ◦ {} = L. L ◦ ∅ = ∅.

Regular Expressions

Kleene Closure

Definition

Ln^ =

{} if n = 0 Ln−^1 ◦ L otherwise