Скачать презентацию Languages 2 nd Sem 2017 Lecture 2 1 Скачать презентацию Languages 2 nd Sem 2017 Lecture 2 1

18a67379820e16a745fd25d0b796dbf4.ppt

  • Количество слайдов: 30

Languages 2 nd Sem 2017 Lecture 2 1 Languages 2 nd Sem 2017 Lecture 2 1

Language: a set of strings String: a sequence of symbols from some alphabet Example: Language: a set of strings String: a sequence of symbols from some alphabet Example: Strings: cat, dog, house Language: {cat, dog, house} Alphabet: 2 nd Sem 2017 Lecture 2 2

Languages are used to describe computation problems: Alphabet: 2 nd Sem 2017 Lecture 2 Languages are used to describe computation problems: Alphabet: 2 nd Sem 2017 Lecture 2 3

Alphabets and Strings An alphabet is a set of symbols Example Alphabet: A string Alphabets and Strings An alphabet is a set of symbols Example Alphabet: A string is a sequence of symbols from the alphabet Example Strings 2 nd Sem 2017 Lecture 2 4

Decimal numbers alphabet Binary numbers alphabet 2 nd Sem 2017 Lecture 2 5 Decimal numbers alphabet Binary numbers alphabet 2 nd Sem 2017 Lecture 2 5

Unary numbers alphabet Unary number: Decimal number: 2 nd Sem 2017 Lecture 2 6 Unary numbers alphabet Unary number: Decimal number: 2 nd Sem 2017 Lecture 2 6

String Operations Concatenation 2 nd Sem 2017 Lecture 2 7 String Operations Concatenation 2 nd Sem 2017 Lecture 2 7

Reverse 2 nd Sem 2017 Lecture 2 8 Reverse 2 nd Sem 2017 Lecture 2 8

String Length: Examples: 2 nd Sem 2017 Lecture 2 9 String Length: Examples: 2 nd Sem 2017 Lecture 2 9

Length of Concatenation Example: 2 nd Sem 2017 Lecture 2 10 Length of Concatenation Example: 2 nd Sem 2017 Lecture 2 10

Empty String A string with no letters is denoted: Observations: 2 nd Sem 2017 Empty String A string with no letters is denoted: Observations: 2 nd Sem 2017 Lecture 2 11

Substring of string: a subsequence of consecutive characters String 2 nd Sem 2017 Substring Substring of string: a subsequence of consecutive characters String 2 nd Sem 2017 Substring Lecture 2 12

Prefix and Suffix Prefixes Suffixes prefix suffix 2 nd Sem 2017 Lecture 2 13 Prefix and Suffix Prefixes Suffixes prefix suffix 2 nd Sem 2017 Lecture 2 13

Another Operation Example: Definition: 2 nd Sem 2017 Lecture 2 14 Another Operation Example: Definition: 2 nd Sem 2017 Lecture 2 14

The * Operation : the set of all possible strings from alphabet 2 nd The * Operation : the set of all possible strings from alphabet 2 nd Sem 2017 Lecture 2 15

The + Operation : the set of all possible strings from alphabet except 2 The + Operation : the set of all possible strings from alphabet except 2 nd Sem 2017 Lecture 2 16

Languages A language over alphabet is any subset of Examples: Language: 2 nd Sem Languages A language over alphabet is any subset of Examples: Language: 2 nd Sem 2017 Lecture 2 17

More Language Examples Alphabet An infinite language 2 nd Sem 2017 Lecture 2 18 More Language Examples Alphabet An infinite language 2 nd Sem 2017 Lecture 2 18

Prime numbers Alphabet Language: 2 nd Sem 2017 Lecture 2 19 Prime numbers Alphabet Language: 2 nd Sem 2017 Lecture 2 19

Even and odd numbers Alphabet 2 nd Sem 2017 Lecture 2 20 Even and odd numbers Alphabet 2 nd Sem 2017 Lecture 2 20

Unary Addition Alphabet: Language: 2 nd Sem 2017 Lecture 2 21 Unary Addition Alphabet: Language: 2 nd Sem 2017 Lecture 2 21

Squares Alphabet: Language: 2 nd Sem 2017 Lecture 2 22 Squares Alphabet: Language: 2 nd Sem 2017 Lecture 2 22

Note that: Sets Set size String length 2 nd Sem 2017 Lecture 2 23 Note that: Sets Set size String length 2 nd Sem 2017 Lecture 2 23

Operations on Languages The usual set operations Complement: 2 nd Sem 2017 Lecture 2 Operations on Languages The usual set operations Complement: 2 nd Sem 2017 Lecture 2 24

Reverse Definition: Examples: 2 nd Sem 2017 Lecture 2 25 Reverse Definition: Examples: 2 nd Sem 2017 Lecture 2 25

Concatenation Definition: Example: 2 nd Sem 2017 Lecture 2 26 Concatenation Definition: Example: 2 nd Sem 2017 Lecture 2 26

Another Operation Definition: Special case: 2 nd Sem 2017 Lecture 2 27 Another Operation Definition: Special case: 2 nd Sem 2017 Lecture 2 27

2 nd Sem 2017 Lecture 2 28 2 nd Sem 2017 Lecture 2 28

Star-Closure (Kleene *) All strings that can be constructed from Definition: Example: 2 nd Star-Closure (Kleene *) All strings that can be constructed from Definition: Example: 2 nd Sem 2017 Lecture 2 29

Positive Closure Definition: Same with 2 nd Sem 2017 but without the Lecture 2 Positive Closure Definition: Same with 2 nd Sem 2017 but without the Lecture 2 30