300 likes | 415 Views
Languages. Language: a set of strings String: a sequence of symbols from some alphabet Example: Strings: cat, dog, house Language: {cat, dog, house}. Alphabet:. Languages are used to describe computation problems:. Alphabet:. Alphabets and Strings.
E N D
Languages Costas Busch - RPI
Language: a set of strings • String:a sequence of symbols • from some alphabet • Example: • Strings: cat, dog, house • Language: {cat, dog, house} Alphabet: Costas Busch - RPI
Languages are used to describe computation problems: Alphabet: Costas Busch - RPI
Alphabets and Strings An alphabet is a set of symbols Example Alphabet: A string is a sequence of symbols from the alphabet Example Strings Costas Busch - RPI
Decimal numbers alphabet Binary numbers alphabet Costas Busch - RPI
Unary numbers alphabet Unary number: Decimal number: Costas Busch - RPI
String Operations Concatenation Costas Busch - RPI
Reverse Costas Busch - RPI
String Length • Length: • Examples: Costas Busch - RPI
Length of Concatenation • Example: Costas Busch - RPI
Empty String • A string with no letters is denoted: • Observations: Costas Busch - RPI
Substring • Substring of string: • a subsequence of consecutive characters • String Substring Costas Busch - RPI
Prefix and Suffix • Prefixes Suffixes prefix suffix Costas Busch - RPI
Another Operation • Example: • Definition: Costas Busch - RPI
The * Operation • : the set of all possible strings from • alphabet Costas Busch - RPI
The + Operation : the set of all possible strings from alphabet except Costas Busch - RPI
Languages • A language over alphabet • is any subset of • Examples: Language: Language: Language: Costas Busch - RPI
More Language Examples • An infinite language Alphabet Costas Busch - RPI
Prime numbers Alphabet Language: Costas Busch - RPI
Even and odd numbers Alphabet Costas Busch - RPI
Unary Addition Alphabet: Language: Costas Busch - RPI
Squares Alphabet: Language: Costas Busch - RPI
Note that: Sets Set size Set size String length Costas Busch - RPI
Operations on Languages • The usual set operations • Complement: Costas Busch - RPI
Reverse • Definition: • Examples: Costas Busch - RPI
Concatenation • Definition: • Example: Costas Busch - RPI
Another Operation • Definition: • Special case: Costas Busch - RPI
Star-Closure (Kleene *) • All strings that can be constructed from • Definition: • Example: Costas Busch - RPI
Positive Closure • Definition: Same with but without the Costas Busch - RPI