Regular Languages Sequential Machine Theory Prof. K. J. Hintz Department of Electrical and Computer Engineering Lecture 3 Comments, additions and modifications.

Slides:



Advertisements
Similar presentations
Chapter 2 Revision of Mathematical Notations and Techniques
Advertisements

Why empty strings? A bit like zero –you may think you can do without –but it makes definitions & calculations easier Definitions: –An alphabeth is a finite.
Theory Of Automata By Dr. MM Alam
1 Lecture 32 Closure Properties for CFL’s –Kleene Closure construction examples proof of correctness –Others covered less thoroughly in lecture union,
COMP-421 Compiler Design Presented by Dr Ioanna Dionysiou.
Recursive Definitions and Structural Induction
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.
Finite Automata Great Theoretical Ideas In Computer Science Anupam Gupta Danny Sleator CS Fall 2010 Lecture 20Oct 28, 2010Carnegie Mellon University.
Equivalence, DFA, NDFA Sequential Machine Theory Prof. K. J. Hintz Department of Electrical and Computer Engineering Lecture 2 Updated and modified by.
Regular Languages Sequential Machine Theory Prof. K. J. Hintz Department of Electrical and Computer Engineering Lecture 3 Comments, additions and modifications.
Deterministic FA/ PDA Sequential Machine Theory Prof. K. J. Hintz Department of Electrical and Computer Engineering Lecture 4 Updated by Marek Perkowski.
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...
Costas Busch - RPI1 Mathematical Preliminaries. Costas Busch - RPI2 Mathematical Preliminaries Sets Functions Relations Graphs Proof Techniques.
Normal forms for Context-Free Grammars
Courtesy Costas Busch - RPI1 Mathematical Preliminaries.
Topics Automata Theory Grammars and Languages Complexities
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,
Introduction to CS Theory Lecture 1 – Introduction Piotr Faliszewski
Chapter 2 Languages.
Section 5.3. Section Summary Recursively Defined Functions Recursively Defined Sets and Structures Structural Induction.
CSC312 Automata Theory Lecture # 2 Languages.
CSC312 Automata Theory Lecture # 2 Languages.
1 Chapter 1 Automata: the Methods & the Madness Angkor Wat, Cambodia.
Formal Methods in SE Theory of Automata Qasiar Javaid Assistant Professor Lecture # 06.
Lecture Two: Formal Languages Formal Languages, Lecture 2, slide 1 Amjad Ali.
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.
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 Exercise: Prove that the set S = { π : π is a permutation of {1, 2, 3, …, n} for some integer n ≥ 1 } is countable.
Chapter 5: Sequences, Mathematical Induction, and Recursion 5.9 General Recursive Definitions and Structural Induction 1 Erickson.
Recursive Definitions & Regular Expressions (RE)
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.
1 Recap lecture 27 Pumping lemma version II, proof, examples, Myhill Nerode theorem, examples.
Specifying Languages Our aim is to be able to specify languages for use in the computer. The sketch of an FSA is easy for us to understand, but difficult.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 2 Mälardalen University 2010.
CS 103 Discrete Structures Lecture 13 Induction and Recursion (1)
1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 2 School of Innovation, Design and Engineering Mälardalen University 2012.
CS 203: Introduction to Formal Languages and Automata
Recursive Definations Regular Expressions Ch # 4 by Cohen
Classifications LanguageGrammarAutomaton Regular, right- linear Right-linear, left-linear DFA, NFA Context-free PDA Context- sensitive LBA Recursively.
CompSci 102 Discrete Math for Computer Science March 13, 2012 Prof. Rodger Slides modified from Rosen.
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.
1 Chapter 3 Regular Languages.  2 3.1: Regular Expressions (1)   Regular Expression (RE):   E is a regular expression over  if E is one of:
Set, Alphabets, Strings, and Languages. The regular languages. Clouser properties of regular sets. Finite State Automata. Types of Finite State Automata.
Lecture 03: Theory of Automata:2014 Asif Nawaz Theory of 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.
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.
Theory of Computation Lecture #
Lecture # 2.
Languages.
Languages Prof. Busch - LSU.
Languages Costas Busch - LSU.
Deterministic FA/ PDA Sequential Machine Theory Prof. K. J. Hintz
LANGUAGES Prepared by: Paridah Samsuri Dept. of Software Engineering
Equivalence, DFA, NDFA Sequential Machine Theory Prof. K. J. Hintz
Assume that p, q, and r are in
Specification of tokens using regular expressions
Introduction Reading: Sections 1.5 – 1.7.
Chapter 1 Introduction to the Theory of Computation
CSC312 Automata Theory Lecture # 2 Languages.
LECTURE # 07.
Languages Fall 2018.
Presentation transcript:

Regular Languages Sequential Machine Theory Prof. K. J. Hintz Department of Electrical and Computer Engineering Lecture 3 Comments, additions and modifications by Marek Perkowski

Languages Informal Languages –English –Body –Bureaucratize Formal Languages –Rule-based –Elements are decidable –No deeper understanding required

Formal Language All the Rules of the Language Are Explicitly Stated in Terms of the Allowed Strings of Symbols, e.g., –Programming languages, e.g., C, Lisp, Ada –Military communications (formal “informal” L ) –Digital network protocols

A to... Alphabet: a finite set of symbols, aka I,  –Roman: { a, b, c,..., z } –Binary:{ 0, 1 } –Greek:{  } –Cyrillic:{ Ж, Й, Њ, С, Р,... }

String String, word: a finite ordered sequence of symbols from the alphabet, usually written with no intervening punctuation –x 1 = “ t h e “ –x 2 = “ “ –x 3 = “ “ –x 4 = “ Ж Й С Р “

String Reverse of String –The sequence of symbols written backwards Reverse of Concatenation –Strings themselves must be reversed

String Length or Size of String –The number of symbols

Strings Null String, Empty String, e,  –A string of length or size zero –The symbols e or , meant to denote the null string, are not allowed to be part of the language

Substring A String, v, Is a Substring of a String, w, iff There Are Strings x and y Such That –w = x v y –x is called the prefix –y is called the suffix –x and/or y could be 

Kleene Closure Set of All Strings,  *, I* –Order IS important –Not the same as, the powerset of the alphabet, since order is NOT important in the powerset

Concatenation Operator If x, y  I*, then the concatenation of x and y is written as –z = x  y –e.g., if x = “Red”| x | = 3 y = “skins”| y | = 5 z = x  y = “Redskins“| z | = 8

Concatenation Operator Concatenation of Any String With the Null String Results in the Original String –x  e = e  x = x –x   =   x = x Concatenation is Associative –x = abcy=defz= ghi –( x  y )  z = x  ( y  z ) –abcdefghi = abcdefghi

Language Language, L : Any Subset of the Set of All Strings of an Alphabet I*I* L1L1 L2L2

Classes of Languages Enumerated Languages –Defined by a List of All Words in the Language L e = { “quidditch”, “nimbus 2000”, } not very interesting Rule-based –Defined by Properties or a Set of Rules

Rule Based Languages A Test to Determine Whether a String Is a Member of a Language A Means of Constructing Strings That Are in the Language –Must be able to construct ALL strings in the language –Must be able to construct ONLY strings in the language

Rule-Based Language Example Let I = { a, b } A Language That Consists of All Two Letter Strings – L = { aa, ab, ba, bb } –  is not an element of the language

Empty Language Null Language, Empty Language,  : The Language With No Words in It –Not the same as  –  can be made into a language with words –A language consisting only of  is still a language

Kleene Star If is a language, then L * Is the Set of All Strings Obtained by Concatenating Zero or More Strings of L. Concatenation of Zero Strings Is  Concatenation of One String Is the String Itself L + = L * - {  }

Kleene Closure Example L = { 0, 1} L * = { , 0, 00, 000,..., 0*, 1, 11, 111,..., 1*, 01, 001, 0001,..., 0*1,... }

Kleene Closure Examples L = { ab, f } L * = { , ab, abf, fab, ffab, ffabf,... }  * = {  } if L = {  } then L * = {  }

Kleene Closure Examples Let I = { a, b } L = Language ( ( ab )* ) { , ab, abab, ababab,... } which is not the same as L = Language ( a* b* ) { , a, b, ab, aab, abb,... } The language of all strings of a’s and b’s in which the a’s, if any, come before the b’s

Recursive Language Definition Variation of Rule-Based Three-step Process 1. Specify some basic elements of the set 2. Specify the rules for forming new elements from old elements of the set 3. Specify that elements not in 1 or 2 above are NOT elements of the set

Recursive Example Two Equivalent Recursive Definitions of Rational Numbers –Rational #1 1. Rat_1 = { - ,... -3, -2, -1, 1, 2, 3,...,  } 2. if p, q  Rat_1, then p/q  Rat_1 3. the only rational numbers are those generated by 1 and 2 above.

Recursive Example –Rational #2 1. Rat_2 = { -1, +1 } 2. if p, q  Rat_2, p,q != 0, then (p+q)/p  Rat_2 3. the only rational numbers are those generated by 1 and 2 above. e.g., generates all integers

Interest in Recursive Definitions Allows Us to Prove Some Statements About What Is Computable. Leads to Proof by Induction

Principle of Mathematical Induction* Let A Be a Subset of the Natural Numbers 0  A, and for each natural number, n, –if { 0, 1,..., n }  A, –implies(n + 1)  A –then A = N * Lewis & Papadimitriou, pg. 24

Mathematical Induction In practice, mathematical induction is used to prove assertions of the form For all natural numbers, n, property P is true

Mathematical Induction Practice To prove statements of the form A = { n : P is true of n }, three steps 1. Basis Step: show that 0  A, i.e., P is true of n = 0 2. Induction Hypothesis: assume that for some arbitrary, but fixed n > 0, P holds for each natural number 0, 1,..., n

Mathematical Induction Practice 3. Induction Step: use the induction hypothesis (that P is true of n) to show that P is true of (n + 1) By the Induction Principle, Then A=N and Hence, P Is True of Every Natural Number.

Induction Example* * Lewis & Papadimitriou, pg Basis Step

Induction Example 2. Induction Hypothesis

Induction Example 3. Induction Step

Induction Example

Another Induction Example Define EVEN as 1. 0 is in EVEN 2. if x  EVEN then so is x The only elements of EVEN are those produced by 1 & 2 above. Prove by induction that all of elements of EVEN end in either 0, 2, 4, 6, or 8.

Induction Example (cont) Proof 1. Basis Step 0  EVEN by definition, therefore the property is true of the zero’th step since 0  { 0, 2, 4, 6, 8 } 2. Induction Hypothesis Assume that the last digit of (m+2)  { 0, 2, 4, 6, 8 } for 0 < m < n

Induction Example 3. Induction Step n  EVEN n2n n+1(2n+2)+2 38n+12(n+1) ends in {0,2,4,6,8} by step 2 0+2=2, 2+2=4,4+2=6 6+2=8, 8+2=0  {0,2,4,6,8}

Regular Expressions Shorthand Notation for Concisely Expressing Languages Defined Recursively Lead to a Definition of Regular Languages Provide Finite Representation of Possibly Infinite Languages Lead to Lexical Analyzers

Regular Expressions Notation

Regular Expressions Over I  and  are regular expressions a is a regular expression for each a  I If r and s are regular expressions, then so are r  s, r  s, and r* No other sequences of symbols are regular expressions

Regular Expressions Alternative 1. L (  ) = {  } L ( a ) = { a } If p and q are regular expressions, then 2. L ( pq ) = L ( p ) L ( q ) 3. L ( p  q ) = L ( p )  L ( q ) 4. L ( p* ) = L ( p )*

Regular Expressions Example What is L 3 ( ( a  b )* a ) ?

Regular Expressions Boolean OR Distributes over Concatenation –which is the language of all strings beginning with a, ending with b, and having none or more c’s in the middle, and, –all strings beginning and ending with b and having at least one c in the middle

Regular Expressions The Boolean OR Operator Can Distribute When It Is Inside a Kleene Starred Expression, but Only in Certain Ways

Regular Expressions Useful String –( a + b )* = the set of all strings of a and b of any length – L = Language ( ( a + b )* ) –{ , ab, abab, abaab, abbaab, babba, bbb,... }

Regular Languages If L  I* is finite, then L is regular. If L 1 and L 2 are regular, so are – L 3 = L 1  L 2 – L 4 = L 1  L 2 = {x 1  x 2 | x 1  L 1, x 2  L 2 } If L is regular, then so is L *, where * is the Kleene Star

Regular Languages If L Is a Finite Language, Then L Can Be Defined by a Regular Expression. The Converse Is Not True. That Is, Not All Regular Expressions Represent Finite Languages. L = Language( ( a + b )* ) Is Infinite Yet Regular