Alphabet, String, Language. 2 Alphabet and Strings An alphabet is a finite, non-empty set of symbols. –Denoted by  –{ 0, 1 } is a binary alphabet. –{

Slides:



Advertisements
Similar presentations
CS2303-THEORY OF COMPUTATION Closure Properties of Regular Languages
Advertisements

Properties of Regular Sets
Formal Languages Languages: English, Spanish,... PASCAL, C,... Problem: How do we define a language? i.e. what sentences belong to a language? e.g.Large.
Properties of Regular Languages
Natural Language Processing - Formal Language - (formal) Language (formal) Grammar.
YES-NO machines Finite State Automata as language recognizers.
1 Languages. 2 A language is a set of strings String: A sequence of letters Examples: “cat”, “dog”, “house”, … Defined over an alphabet: Languages.
1 CSCI-2400 Models of Computation. 2 Computation CPU memory.
Regular Languages Sequential Machine Theory Prof. K. J. Hintz Department of Electrical and Computer Engineering Lecture 3 Comments, additions and modifications.
CS 310 – Fall 2006 Pacific University CS310 Strings, String Operators, and Languages Sections: August 30, 2006.
1 Languages and Finite Automata or how to talk to machines...
CS5371 Theory of Computation Lecture 1: Mathematics Review I (Basic Terminology)
Costas Busch - RPI1 Mathematical Preliminaries. Costas Busch - RPI2 Mathematical Preliminaries Sets Functions Relations Graphs Proof Techniques.
Courtesy Costas Busch - RPI1 Mathematical Preliminaries.
Theoretical Computer Science COMP 335 Fall 2004
Fall 2006Costas Busch - RPI1 Languages. Fall 2006Costas Busch - RPI2 Language: a set of strings String: a sequence of symbols from some alphabet Example:
Fall 2004COMP 3351 Languages. Fall 2004COMP 3352 A language is a set of strings String: A sequence of letters/symbols Examples: “cat”, “dog”, “house”,
1 Regular Expressions/Languages Regular languages –Inductive definitions –Regular expressions syntax semantics Not covered in lecture.
Lecture 1 String and Language. String string is a finite sequence of symbols. For example, string ( s, t, r, i, n, g) CS4384 ( C, S, 4, 3, 8) (1,
Regular Languages A language is regular over  if it can be built from ;, {  }, and { a } for every a 2 , using operators union ( [ ), concatenation.
UofH - COSC Dr. Verma COSC 3340: Introduction to Theory of Computation Rakesh Verma Computer Science Department University of Houston URL:
1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 5 School of Innovation, Design and Engineering Mälardalen University 2012.
Welcome to Honors Intro to CS Theory Introduction to CS Theory (Honors & Traditional): - formalization of computation - various models of computation (increasing.
CSC312 Automata Theory Lecture # 2 Languages.
CSC312 Automata Theory Lecture # 2 Languages.
Costas Busch - LSU1 Languages. Costas Busch - LSU2 Language: a set of strings String: a sequence of symbols from some alphabet Example: Strings: cat,
1 Chapter 1 Automata: the Methods & the Madness Angkor Wat, Cambodia.
1 Strings and Languages. 2 Review Sets and sequences Functions and relations Graphs Boolean logic:      Proof techniques: – Construction, Contradiction,
Introduction to CS Theory Lecture 3 – Regular Languages Piotr Faliszewski
1 Chapter 1 Introduction to the Theory of Computation.
Mathematical Preliminaries. Sets Functions Relations Graphs Proof Techniques.
1 Languages. 2 A language is a set of strings String: A sequence of letters Examples: “cat”, “dog”, “house”, … Defined over an alphabet:
Welcome to Honors Intro to CS Theory Introduction to CS Theory (Honors & Traditional): - formalization of computation - various models of computation (increasing.
1 Exercise: Prove that the set S = { π : π is a permutation of {1, 2, 3, …, n} for some integer n ≥ 1 } is countable.
1 Module 14 Regular languages –Inductive definitions –Regular expressions syntax semantics.
Strings and Languages CS 130: Theory of Computation HMU textbook, Chapter 1 (Sec 1.5)
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 2 Mälardalen University 2010.
Strings and Languages Denning, Section 2.7. Alphabet An alphabet V is a finite nonempty set of symbols. Each symbol is a non- divisible or atomic object.
Theory of computation Introduction theory of computation: It comprises the fundamental mathematical properties of computer hardware, software,
Introduction Why do we study Theory of Computation ?
Introduction Why do we study Theory of Computation ?
Set, Alphabets, Strings, and Languages. The regular languages. Clouser properties of regular sets. Finite State Automata. Types of Finite State Automata.
1 Let S = { π : π is a permutation of {1, 2, 3, …, n} for some integer n ≥ 1 }. (a) List the elements of S for n= 1, 2, and 3. (b) Prove that the set S.
Dept. of Computer Science & IT, FUUAST Automata Theory 2 Automata Theory III Properties of Regular Languages 1.Closure 2.Union 3.Concatenation 4.Complement(Negation)
Languages and Strings Chapter 2. (1) Lexical analysis: Scan the program and break it up into variable names, numbers, etc. (2) Parsing: Create a tree.
Introduction Why do we study Theory of Computation ?
General Discussion of “Properties” The Pumping Lemma Membership, Emptiness, Etc.
Languages.
Why do we study Theory of Computation ?
CIS Automata and Formal Languages – Pei Wang
Closure Properties of Regular Languages
Languages Prof. Busch - LSU.
Languages Costas Busch - LSU.
PROPERTIES OF REGULAR LANGUAGES
Natural Language Processing - Formal Language -
Languages, prefixes, sets, cardinality, functions
Assume that p, q, and r are in
Why do we study Theory of Computation ?
COSC 3340: Introduction to Theory of Computation
CSE322 CONSTRUCTION OF FINITE AUTOMATA EQUIVALENT TO REGULAR EXPRESSION Lecture #9.
Closure Properties of Regular Languages
Closure Properties of Regular Languages
Languages, prefixes, sets, cardinality, functions
Introduction Reading: Sections 1.5 – 1.7.
CSE 105 theory of computation
COSC 3340: Introduction to Theory of Computation
CSC312 Automata Theory Lecture # 2 Languages.
Languages Fall 2018.
Terminology and Symbols
CSE 105 theory of computation
Presentation transcript:

Alphabet, String, Language

2 Alphabet and Strings An alphabet is a finite, non-empty set of symbols. –Denoted by  –{ 0, 1 } is a binary alphabet. –{ A, B, …, Z, a, b, …, z } is an English alphabet. A string over an alphabet  is a sequence of any number of symbols from . –0, 1, 11, 00, and are strings over { 0, 1 }. –Cat, CAT, and compute are strings over the English alphabet.

3 Empty String An empty string, denoted by , is a string containing no symbol. –  is a string over any alphabet.

4 Length The length of a string x, denoted by length(x), is the number of positions of symbols in the string. Let Σ = { a, b, …, z } length ( automata ) = 8 length(computation) = 11 length ( ε ) = 0 x(i), denotes the symbol in the i th position of a string x, for 1  i  length(x).

5 String Operations Concatenation Substring Reversal

6 Concatenation The concatenation of strings x and y, denoted by x  y or x y, is a string z such that: –z ( i ) = x ( i ) for 1  i  length ( x ) –z ( i ) = y ( i ) for length ( x )< i  length ( x )+ length ( y ) Example –automata  computation = automatacomputation

7 Concatenation The concatenation of string x for n times, where n  0, is denoted by x n –x 0 =  –x 1 = x –x 2 = x x –x 3 = x x x – …– …

8 Substring Let x and y be strings over an alphabet Σ The string x is a substring of y if there exist strings w and z over Σ such that y = w x z. –ε is a substring of every string. –For every string x, x is a substring of x itself. Example –ε, comput and computation are substrings of computation.

9 Reversal Let x be a string over an alphabet Σ The reversal of the string x, denoted by x r, is a string such that –if x is ε, then x r is ε. –If a is in Σ, y is in Σ * and x = a y, then x r = y r a.

10 Example of Reversal (automata) r = (utomata) r a = (tomata) r ua = (omata) r tua = (mata) r otua = (ata) r motua = (ta) r amotua = (a) r tamotua = (  ) r atamotua = atamotua

Power of Alphabet 11 If Σ is an alphabet, we can express the set of all strings of a certain length from that alphabet by using an exponential notation. We define Σ k to be the set of strings of length k, each of whose symbols is in the Σ. If Σ = {0,1} then Σ 1 = {0,1}, Σ 2 = {00,01,10,11}….. The set of all strings over an alphabet Σ is conventionally denoted by Σ *.

12 Σ*Σ* The set of all strings over an alphabet Σ is conventionally denoted by Σ *. That is,  * =  i=  0  I Σ * = Σ 0 U Σ 1 U Σ 2 ….. –Let  = { 0, 1 }. –  * = { , 0, 1, 00, 01, 10, 11, 000, 001, 010, 011, … }.

13 Σ+Σ+ The set of strings created from at least one symbol (1 or 2 or …) in an alphabet  is denoted by  +. That is,  + =  i=  1  i =  i=0..   i -  0 =  i=0..   i - {  } Let  = { 0, 1 }.  + = { 0, 1, 00, 01, 10, 11, 000, 001, 010, 011, … }.  * and  + are infinite sets.

14 Languages A language over an alphabet Σ is a set of strings over Σ. –Let Σ = {0, 1} be the alphabet. –L e = {  Σ * | the number of 1 ’ s in  is even}. – , 0, 00, 11, 000, 110, 101, 011, 0000, 1100, 1010, 1001, 0110, 0101, 0011, … are in L e

15 Operations on Languages Complementation Union Intersection Concatenation Reversal Closure

16 Complementation Let L be a language over an alphabet Σ. The complementation of L, denoted by  L, is Σ *– L. Example: Let Σ = {0, 1} be the alphabet. L e = {  Σ * | the number of 1 ’ s in  is even}.  L e = {  Σ * | the number of 1 ’ s in  is not even}.  L e = {  Σ * | the number of 1 ’ s in  is odd}.

17 Union Let L 1 and L 2 be languages over an alphabet Σ. The union of L 1 and L 2, denoted by L 1  L 2, is { x | x is in L 1 or L 2 }. Example: { x  {0,1}*| x begins with 0}  { x  {0,1}*| x ends with 0} = { x  {0,1}*| x begins or ends with 0}

18 Intersection Let L 1 and L 2 be languages over an alphabet Σ. The intersection of L 1 and L 2, denoted by L 1  L 2, is { x | x is in L 1 and L 2 }. Example: { x  {0,1}*| x begins with 0}  { x  {0,1}*| x ends with 0} = { x  {0,1}*| x begins and ends with 0}

19 Concatenation Let L 1 and L 2 be languages over an alphabet Σ. The concatenation of L 1 and L 2, denoted by L 1  L 2, is { w 1  w 2 | w 1 is in L 1 and w 2 is in L 2 }. Example { x  {0,1}*| x begins with 0}  { x  {0,1}*| x ends with 0} = { x  {0,1}*| x begins and ends with 0 and length(x)  2} { x  {0,1}*| x ends with 0}  { x  {0,1}*| x begins with 0} = { x  {0,1}*| x has 00 as a substring}

20 Reversal Let L be a language over an alphabet Σ. The reversal of L, denoted by L r, is { w r | w is in L }. Example { x  {0,1}*| x begins with 0} r = { x  {0,1}*| x ends with 0} { x  {0,1}*| x has 00 as a substring} r = { x  {0,1}*| x has 00 as a substring}

21 Kleene’s closure Let L be a language over an alphabet Σ. The Kleene ’ s closure of L, denoted by L*, is { x | for an integer n  0 x = x 1 x 2 … x n and x 1, x 2, …, x n are in L }. That is, L* =  i  = 0 L i Example: Let Σ = {0,1} and L e = {  Σ * | the number of 1 ’ s in  is even} L e * = {  Σ * | the number of 1 ’ s in  is even} (  L e )* = {  Σ *| the number of 1 ’ s in  is odd}* = {  Σ *| the number of 1 ’ s in  > 0}

22 Closure Let L be a language over an alphabet Σ. The closure of L, denoted by L +, is { x |for an integer n  1, x = x 1 x 2 …x n and x 1, x 2, …, x n are in L } That is, L + =  i  = 1 L i Example: Let Σ = { 0, 1 } be the alphabet. L e = {  Σ * | the number of 1 ’ s in  is even} L e + = {  Σ * | the number of 1 ’ s in  is even} = L e *

23 Observation about Closure L + = L *  { ε } ? Example: L = {  Σ * | the number of 1 ’ s in  is even} L + = {  Σ * | the number of 1 ’ s in  is even} = L e * Why? L * = L +  { ε } ?

24 Languages and Problems Problem –Example: What are prime numbers > 20? Decision problem –Problem with a YES/NO answer –Example: Given a positive integer n, is n a prime number > 20? Language –Example: { n | n is a prime number > 20} = {23, 29, 31, 37, …}

25 Language Recognition and Problem A problem is represented by a set of strings of the input whose answer for the corresponding problem is “YES”. a string is in a language = the answer of the corresponding problem for the string is “YES” –Let “Given a positive integer n, is n a prime number > 20?” be the problem P. –If a string represents an integer i in { m | m is a prime number > 20}, then the answer for the problem P for n = i is true.