Languages Fall 2004 COMP 335 1 A language

  • Slides: 23
Download presentation
Languages Fall 2004 COMP 335 1

Languages Fall 2004 COMP 335 1

A language is a set of strings String: A sequence of letters/symbols Examples: “cat”,

A language is a set of strings String: A sequence of letters/symbols Examples: “cat”, “dog”, “house”, … Defined over an alphabet: Fall 2004 COMP 335 2

Alphabets and Strings We will use small alphabets: Strings Fall 2004 COMP 335 3

Alphabets and Strings We will use small alphabets: Strings Fall 2004 COMP 335 3

String Operations Concatenation Fall 2004 COMP 335 4

String Operations Concatenation Fall 2004 COMP 335 4

Reverse Fall 2004 COMP 335 5

Reverse Fall 2004 COMP 335 5

String Length: Examples: Fall 2004 COMP 335 6

String Length: Examples: Fall 2004 COMP 335 6

Length of Concatenation Example: Fall 2004 COMP 335 7

Length of Concatenation Example: Fall 2004 COMP 335 7

The Empty String A string with no letters: Observations: Fall 2004 COMP 335 8

The Empty String A string with no letters: Observations: Fall 2004 COMP 335 8

Substring of string: a subsequence of consecutive characters String Fall 2004 Substring COMP 335

Substring of string: a subsequence of consecutive characters String Fall 2004 Substring COMP 335 9

Prefix and Suffix Prefixes Suffixes prefix suffix Fall 2004 COMP 335 10

Prefix and Suffix Prefixes Suffixes prefix suffix Fall 2004 COMP 335 10

Another Operation Example: Definition: Fall 2004 COMP 335 11

Another Operation Example: Definition: Fall 2004 COMP 335 11

The * Operation : the set of all possible strings from alphabet Fall 2004

The * Operation : the set of all possible strings from alphabet Fall 2004 COMP 335 12

The + Operation : the set of all possible strings from alphabet except Fall

The + Operation : the set of all possible strings from alphabet except Fall 2004 COMP 335 13

Languages A language is any subset of Example: Languages: Fall 2004 COMP 335 14

Languages A language is any subset of Example: Languages: Fall 2004 COMP 335 14

Note that: Sets Set size String length Fall 2004 COMP 335 15

Note that: Sets Set size String length Fall 2004 COMP 335 15

Another Example An infinite language Fall 2004 COMP 335 16

Another Example An infinite language Fall 2004 COMP 335 16

Operations on Languages The usual set operations Complement: Fall 2004 COMP 335 17

Operations on Languages The usual set operations Complement: Fall 2004 COMP 335 17

Reverse Definition: Examples: Fall 2004 COMP 335 18

Reverse Definition: Examples: Fall 2004 COMP 335 18

Concatenation Definition: Example: Fall 2004 COMP 335 19

Concatenation Definition: Example: Fall 2004 COMP 335 19

Another Operation Definition: Special case: Fall 2004 COMP 335 20

Another Operation Definition: Special case: Fall 2004 COMP 335 20

More Examples Fall 2004 COMP 335 21

More Examples Fall 2004 COMP 335 21

Star-Closure (Kleene *) Definition: Example: Fall 2004 COMP 335 22

Star-Closure (Kleene *) Definition: Example: Fall 2004 COMP 335 22

Positive Closure Definition: Fall 2004 COMP 335 23

Positive Closure Definition: Fall 2004 COMP 335 23