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) 101001 (1,

Slides:



Advertisements
Similar presentations
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.
Advertisements

Chapter 6 Languages: finite state machines
Properties of Regular Languages
Lecture 9,10 Theory of AUTOMATA
COMP-421 Compiler Design Presented by Dr Ioanna Dionysiou.
1 Languages. 2 A language is a set of strings String: A sequence of letters Examples: “cat”, “dog”, “house”, … Defined over an alphabet: Languages.
Finite Automata Great Theoretical Ideas In Computer Science Anupam Gupta Danny Sleator CS Fall 2010 Lecture 20Oct 28, 2010Carnegie Mellon University.
Regular Languages Sequential Machine Theory Prof. K. J. Hintz Department of Electrical and Computer Engineering Lecture 3 Comments, additions and modifications.
Sets Definition of a Set: NAME = {list of elements or description of elements} i.e. B = {1,2,3} or C = {x  Z + | -4 < x < 4} Axiom of Extension: A set.
CS 310 – Fall 2006 Pacific University CS310 Strings, String Operators, and Languages Sections: August 30, 2006.
Regular Languages Sequential Machine Theory Prof. K. J. Hintz Department of Electrical and Computer Engineering Lecture 3 Comments, additions and modifications.
1 Languages and Finite Automata or how to talk to machines...
Costas Busch - RPI1 Mathematical Preliminaries. Costas Busch - RPI2 Mathematical Preliminaries Sets Functions Relations Graphs Proof Techniques.
Courtesy Costas Busch - RPI1 Mathematical Preliminaries.
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 A Single Final State for Finite Accepters. 2 Observation Any Finite Accepter (NFA or DFA) can be converted to an equivalent NFA with a single final.
Chapter 2 Languages.
Theory Of Automata By Dr. MM Alam
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.
Formal Methods in SE Theory of Automata Qasiar Javaid Assistant Professor Lecture # 06.
Mathematical Preliminaries Strings and Languages Preliminaries 1.
Lecture Two: Formal Languages Formal Languages, Lecture 2, slide 1 Amjad Ali.
1 Strings and Languages. 2 Review Sets and sequences Functions and relations Graphs Boolean logic:      Proof techniques: – Construction, Contradiction,
Two examples English-Words English-Sentences alphabet S ={a,b,c,d,…}
Introduction to CS Theory Lecture 3 – Regular Languages Piotr Faliszewski
1 Chapter 1 Introduction to the Theory of Computation.
Lecture # 3 Regular Expressions 1. Introduction In computing, a regular expression provides a concise and flexible means to "match" (specify and recognize)
Mathematical Preliminaries (Hein 1.1 and 1.2) Sets are collections in which order of elements and duplication of elements do not matter. – {1,a,1,1} =
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 2 Mälardalen University 2006.
Module 2 How to design Computer Language Huma Ayub Software Construction Lecture 8.
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:
Regular Expressions and Languages A regular expression is a notation to represent languages, i.e. a set of strings, where the set is either finite or contains.
Strings and Languages CS 130: Theory of Computation HMU textbook, Chapter 1 (Sec 1.5)
Chapter 4 Pumping Lemma Properties of Regular Languages Decidable questions on Regular Languages.
Theory of Computation, Feodor F. Dragan, Kent State University 1 TheoryofComputation Spring, 2015 (Feodor F. Dragan) Department of Computer Science Kent.
1 String v is a prefix of w if w= v y for some string y. String v is a suffix of w if w= x v for some string x. String v is a substring of w if there are.
Class Discussion Can you draw a DFA that accepts the language {a k b k | k = 0,1,2,…} over the alphabet  ={a,b}?
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 2 Mälardalen University 2010.
CS 203: Introduction to Formal Languages and Automata
نظام المحاضرات الالكترونينظام المحاضرات الالكتروني Theory of Automata We will arrive at what we may believe to be the most powerful machine possible. When.
Chapter 3 Regular Expressions, Nondeterminism, and Kleene’s Theorem Copyright © 2011 The McGraw-Hill Companies, Inc. Permission required for reproduction.
Regular Languages ภาษาปกติ. Jaruloj Chongstitvatana Outline Regular expressions Regular languages Equivalence between languages accepted by.
Lecture 2 Overview Topics What I forgot from last lecture Proof techniques continued Alphabets, strings, languages Automata June 2, 2015 CSCE 355 Foundations.
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.
Lecture # 4.
Finite Automata Great Theoretical Ideas In Computer Science Victor Adamchik Danny Sleator CS Spring 2010 Lecture 20Mar 30, 2010Carnegie Mellon.
Lecture 02: Theory of Automata:2014 Asif Nawaz Theory of Automata.
CS 154 Formal Languages and Computability March 17 Class Meeting Department of Computer Science San Jose State University Spring 2016 Instructor: Ron Mak.
Lecture 03: Theory of Automata:2014 Asif Nawaz Theory of Automata.
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. –{
Lecture # 2.
Languages.
Languages Prof. Busch - LSU.
Languages Costas Busch - LSU.
PROPERTIES OF REGULAR LANGUAGES
LANGUAGES Prepared by: Paridah Samsuri Dept. of Software Engineering
Lecture 9 Theory of AUTOMATA
Assume that p, q, and r are in
Kleene’s Theorem Muhammad Arif 12/6/2018.
Closure Properties of Regular Languages
Mathematical Preliminaries Strings and Languages
CSE322 Regular Expressions and their Identities
Chapter 1 Introduction to the Theory of Computation
Recap lecture 11 Proof of Kleene’s theorem part II (method with different steps), particular examples of TGs to determine corresponding REs.
Languages Fall 2018.
CSCE 355 Foundations of Computation
Presentation transcript:

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, 0) Symbols are given through alphabet. An alphabet is a finite set of symbols.

Examples of Alphabet {a, b, c,..., x, y, z} (Roman alphabet) {0, 1,..., 9} {0, 1} (binary alphabet)

Length of a String The length of a string x is the number of symbols contained in the string x, denoted by |x|. For example, | string | = 6, |CS5400| = 6, | | = 6. The empty string is a string having no symbol, denoted by ε.

Equal Two strings x 1 x 2 ···x n and y 1 y 2 ···y m are equal if and only if (1) n=m and (2) x i =y i for all i. For example, 01 ≠ 010 and 1010 ≠1110.

Substring s is a substring of x if there exist strings y and z such that x = ysz. In particular, when x = sz (y=ε), s is called a prefix of x; when x = ys (z=ε), s is called a suffix of x. For example, CS is a prefix of CS5400 and 5400 is a surfix of CS5400.

Concatenation The concatenation of two strings x and y is a string xy, i.e., x is followed by y. For example, CS5400 is a concatenation of CS and In particular, we denote xx = x, xxx = x, xxxx = x,..., and define x = ε For example, = (10), (10) = ε

Solve equation 011x=x011 If x=ε, then ok. If |x|=1, then no solution. If |x|=2, then no solution. If |x|>3, then x=011y. Hence, 011x=011y011. So, x=y011. Hence, 011y=y011. x=(011) for k > 0 k

Language A language is a set of strings. For example, {0, 1}, {all English words}, {0, 0, 0,...} are all languages. The following are operations on sets and hence also on languages. Union: A U B Intersection: A ∩ B Difference: A \ B (A - B when B A) Complement: A = Σ* - A where Σ* is the set of all strings on alphabet Σ. 012 _

Concatenation of Languages Concatenation: AB = {ab | a \in A, b \in B} For example, {0, 1}{1, 2} = {01, 02, 11, 12}. Especially, we denote A = A, A = AA,..., and define A = {ε}

If AB=B for any B, then A ={ε}. Choose B = {ε }. Then A ≠ empty and A cannot contain a nonempty string.

Examples For Σ = {0, 1}, Σ = {00, 01, 10, 11}, (Σ is the set of all strings of length k on Σ.) Therefore, Σ* = Σ U Σ U Σ U ··· k

Kleene Closure Kleene closure: A* = A U A U A U ··· Notation: A = A U A U A U ···

A={grand, ε}, B={father, mother}. What is A*B? A*B={father, mother, grandfather, grandmother, …}

What is ? Where is the empty language.

A* = A if and only if ε is in A If ε is in A, then ε is in A. Hence A* = A. If ε is not in A, then ε is not in A. Hence A* ≠ A

{0, 10}* is the language of strings not containing substring 11 and not ending with 1. What is the language of strings not containing substring 11 and ending with 0? {0, 10} +

Puzzle How many strings of length at most 40 are in the following language ?

Lecture 2 Regular Language and Regular Expression.

Regular Languages The concept of regular languages on an alphabet Σ is defined recursively as follows: (1) The empty language is regular. (2) For every symbol a Σ, {a} is regular. (3) If A and B are regular languages, then A U B, AB, and A* are regular. (4) Nothing else is a regular language.

{ε} is regular. Because the empty language is regular, = {ε} is regular.

For Σ={0,1}, {011} is regular. Since {0} and {1} are regular, {011}={0}{1}{1} is regular Remark: Every language containing only one string is regular.

{011,100} is regular. Because {011} and {100} are regular, {011, 100} = {011}U{100} is regular. Remark: Every finite language is regular. Remark: Every infinite regular language must be obtained with Kleene closure.

Operation Preference ({0}*U{0}{1}{1}*){0}{0}{1}* (1) Kleene closure has the higher preference over union and concatenation. (2) Concatenation has the higher preference over union.

The language of all binary strings starting with 01 is regular. Proof. The string in this language is in form 01x 1 ··· x n where x 1 ··· x n {0,1}*. Therefore, the language can be written as {01} {0,1}* = ({0}{1})({0} U {1})*, which is regular.

The language of all binary strings ending at 01 is regular. Proof. The string in this language is in form x 1 ··· x n 01 where x 1 ··· x n {0,1}*. Therefore, the language can be written as {0,1}*{01} = ({0} U {1})*({0}{1}), which is regular.

The language of all binary strings having substring 01 is regular. Proof. The string in this language is in form x 1 ··· x n 01y 1 ··· y m where x 1 ··· x n, y 1 ··· y m {0,1}*. Therefore, the language can be written as {0,1}* {01} {0,1}* =({0}U{1})*({0}{1})({0}U{1})*, which is regular.

Question: Do you fell that the expression of the regular set in the above example contains too many parentheses? Here is a simple expression -- Regular Expression

Regular Expression (1) is a regular expression of the empty language. (2) ε is a regular expression of {ε}. (3) For any symbol a, a is a regular expression of {a}. (4) If r A and r B are regular expressions of languages A and B, then r A +r B is a regular expression of A U B, r A r B is a regular expression of AB, and r A * is a regular expression of A*.

Examples 011 is a regular expression of {0}{1}{1}. 0+1 is a regular expression of {0,1}. (0+1)* is a regular expression of {0,1}*. Remark: (0+1) is also considered to be a regular expression of {0, 1}. + +

The language of all binary strings starting with 01 has a regular expression 01(0+1)*. The language of all binary strings ending at 01 has a regular expression (0+1)*01. The language of all binary strings having substring 01 has a regular expression (0+1)*01(0+1)*.

Induction Proof Because the regular language is defined recursively, we can prove the property of regular languages by proving the following: (1) has the property. (2) For any symbol a Σ, {a} has the property. (3) If A and B has the property, then all A U B, AB, and A* have the property. Actually, this is an induction proof. (1), (2) serve the basis step and (3) is the induction step.

For a string x=x 1 x 2 …x n, x =x n …x 2 x 1. For a language A, A = {x | x A}. Show that if A is regular, so is A. Proof. (1) is regular. (2) For any symbol a, {a} = {a} is regular. (3) Suppose that for regular languages A and B, A and B are regular. Then (A U B) = A U B is regular, (AB) = B A is regular. (A*) = (A )* is regular. R R R R R R R R R R RR RR R

Find a regular expression for {xwx | x (0+1)*, w (0+1)*} {xwx | x (0+1)*, w (0+1)*} = (0+1)* R R

Find a regular expression for {xwx | x (0+1), w (0+1)*} {xwx | x (0+1), w (0+1)*} = 0(0+1)*0 + 1(0+1)*1 R R+ +

Puzzle How many regular expressions can a language have?