CS:4330 Theory of Computation Spring Regular Languages. Finite Automata and Regular Expressions. Haniel Barbosa

Similar documents
Theory of Computation p.1/?? Theory of Computation p.2/?? Unknown: Implicitly a Boolean variable: true if a word is

CS 530: Theory of Computation Based on Sipser (second edition): Notes on regular languages(version 1.1)

COM364 Automata Theory Lecture Note 2 - Nondeterminism

CS 154, Lecture 2: Finite Automata, Closure Properties Nondeterminism,

Formal Definition of Computation. August 28, 2013

Proofs, Strings, and Finite Automata. CS154 Chris Pollett Feb 5, 2007.

Context-Free Languages

Theory of Languages and Automata

Computability Theory

Automata: a short introduction

CS 154. Finite Automata, Nondeterminism, Regular Expressions

Theory of Computation (I) Yijia Chen Fudan University

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

CS21 Decidability and Tractability

Computability Theory

CS 154. Finite Automata vs Regular Expressions, Non-Regular Languages

CS 154, Lecture 3: DFA NFA, Regular Expressions

Lecture 3: Nondeterministic Finite Automata

Finite Automata and Regular languages

Clarifications from last time. This Lecture. Last Lecture. CMSC 330: Organization of Programming Languages. Finite Automata.

Closure under the Regular Operations

UNIT-III REGULAR LANGUAGES

Automata Theory. Lecture on Discussion Course of CS120. Runzhe SJTU ACM CLASS

Nondeterministic Finite Automata

CS21 Decidability and Tractability

Applied Computer Science II Chapter 1 : Regular Languages

CS5371 Theory of Computation. Lecture 5: Automata Theory III (Non-regular Language, Pumping Lemma, Regular Expression)

Theory of Computation Lecture 1. Dr. Nahla Belal

CPS 220 Theory of Computation REGULAR LANGUAGES

Theory of Computation (II) Yijia Chen Fudan University

Theory of computation: initial remarks (Chapter 11)

acs-04: Regular Languages Regular Languages Andreas Karwath & Malte Helmert Informatik Theorie II (A) WS2009/10

UNIT-I. Strings, Alphabets, Language and Operations

PS2 - Comments. University of Virginia - cs3102: Theory of Computation Spring 2010

Great Theoretical Ideas in Computer Science. Lecture 4: Deterministic Finite Automaton (DFA), Part 2

Deterministic Finite Automata. Non deterministic finite automata. Non-Deterministic Finite Automata (NFA) Non-Deterministic Finite Automata (NFA)

Chapter 0 Introduction. Fourth Academic Year/ Elective Course Electrical Engineering Department College of Engineering University of Salahaddin

Examples of Regular Expressions. Finite Automata vs. Regular Expressions. Example of Using flex. Application

CS243, Logic and Computation Nondeterministic finite automata

Computational Models - Lecture 1 1

Introduction to Languages and Computation

Non-deterministic Finite Automata (NFAs)

CMSC 330: Organization of Programming Languages. Theory of Regular Expressions Finite Automata

CSE 135: Introduction to Theory of Computation Nondeterministic Finite Automata (cont )

Finite Automata Part Two

Introduction to Automata

September 11, Second Part of Regular Expressions Equivalence with Finite Aut

Finite Automata. Finite Automata

Computational Models Lecture 2 1

CSE 105 THEORY OF COMPUTATION

Computational Models Lecture 2 1

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Theory of Computation

Deterministic Finite Automata (DFAs)

CS 154 Introduction to Automata and Complexity Theory

Critical CS Questions

CISC 4090: Theory of Computation Chapter 1 Regular Languages. Section 1.1: Finite Automata. What is a computer? Finite automata

Deterministic Finite Automata (DFAs)

Computer Sciences Department

Deterministic Finite Automaton (DFA)

Kleene Algebras and Algebraic Path Problems

CS 133 : Automata Theory and Computability

How do regular expressions work? CMSC 330: Organization of Programming Languages

Formal Definition of a Finite Automaton. August 26, 2013

Chapter Five: Nondeterministic Finite Automata

CSE 105 THEORY OF COMPUTATION

Sri vidya college of engineering and technology

1 Alphabets and Languages

Computational Models: Class 1

Context-Free Languages

September 7, Formal Definition of a Nondeterministic Finite Automaton

Equivalence of DFAs and NFAs

Foundations of

3515ICT: Theory of Computation. Regular languages

CSC173 Workshop: 13 Sept. Notes

Closure under the Regular Operations

Deterministic Finite Automata (DFAs)

Computational Models #1

CSE 105 THEORY OF COMPUTATION

Part I: Definitions and Properties

Regular expressions and Kleene s theorem

CSE 135: Introduction to Theory of Computation Nondeterministic Finite Automata

Introduction to Theoretical Computer Science. Motivation. Automata = abstract computing devices

Automata Theory, Computability and Complexity

UNIT-II. NONDETERMINISTIC FINITE AUTOMATA WITH ε TRANSITIONS: SIGNIFICANCE. Use of ε-transitions. s t a r t. ε r. e g u l a r

Regular Expression Unit 1 chapter 3. Unit 1: Chapter 3

CISC 4090 Theory of Computation

CSE 105 THEORY OF COMPUTATION

Lecture 17: Language Recognition

Automata and Languages

Computational Theory

Harvard CS 121 and CSCI E-207 Lecture 10: Ambiguity, Pushdown Automata

Concatenation. The concatenation of two languages L 1 and L 2

Lecture 1: Finite State Automaton

Languages, regular languages, finite automata

jflap demo Regular expressions Pumping lemma Turing Machines Sections 12.4 and 12.5 in the text

CS 455/555: Finite automata

Deterministic Finite Automata (DFAs)

Outline. CS21 Decidability and Tractability. Regular expressions and FA. Regular expressions and FA. Regular expressions and FA

Before we show how languages can be proven not regular, first, how would we show a language is regular?

Transcription:

CS:4330 Theory of Computation Spring 2018 Regular Languages Finite Automata and Regular Expressions Haniel Barbosa

Readings for this lecture Chapter 1 of [Sipser 1996], 3rd edition. Sections 1.1 and 1.3.

Abstraction of Problems Data: abstracted as a word in a given alphabet Σ: alphabet, a finite, non-empty set of symbols Σ : all the words of finite length built up using Σ Conditions: abstracted as a set of words, called language Any subset L Σ Unknown: Implicitly a Boolean variable: true if a word is in the language, false otherwise Given w Σ and L Σ, does w L? 1 / 14

Finite Automata The simplest computational model is called a finite state machine or a finite automaton Representations: Graphical Tabular Mathematical 2 / 14

Computation of a Finite Automaton The automaton receives the input symbols one by one from left to right, changing the active state After reading each symbol, the active state moves from one state to another along the transition that has that symbol as its label When the last symbol of the input is read the automaton produces the output: accept if the active state is in an accept state, or reject otherwise 3 / 14

Applications Finite automata are popular in parser construction of compilers Finite automata and their probabilistic counterparts, Markov chains, are useful tools for pattern recognition Example: speech processing and optical character recognition Markov chains have been used to model and predict price changes in financial applications 4 / 14

Formal Definition of Finite Automata A finite automaton is a 5-tuple (Q, Σ, δ, q 0, F) in which: Q is a finite set called the states Σ is a finite set called the alphabet δ : Q Σ Q is the transition function q 0 Q is the start state, also called initial stat F Q is the set of accepted states, also called the final states 5 / 14

Language Recognized by an Automaton If L is the set of all strings that a finite automaton M accepts, we say that L is the language of the machine M and write L (M) = L An automaton may accept several strings, but it always recognizes only one language If a machine accepts no strings, it still recognizes one language, namely the empty language 6 / 14

Formal Definition of Acceptance Let M = (Q, Σ, δ, q 0, F) be a finite automaton and w = a 0...a n be a string over Σ Then M accepts w if a sequence of states r 0,..., r n exists in Q such that: 1. r 0 = q 0 2. δ(r i, a i+1 ) = r i+1 for i = 0,1,...,n 1 3. r n F Condition (1) says where the machine starts Condition (2) says that the machine goes from state to state according to its transition function δ Condition (3) says when the machine accepts its input: if it ends up in an accept state 7 / 14

Regular Languages We say that a finite automaton M recognizes the language L if L = {w M accepts w} Definition: A language is called regular language if there exists a finite automaton that recognizes it. 8 / 14

Designing Finite Automata Whether it be of automaton or artwork, design is a creative process. Consequently it cannot be reduced to a simple recipe or formula. The approach: Identify the finite pieces of information you need to solve the problem. These are the states Identify the condition (alphabet) to change from one state to another Identify the start and final states Add missing transitions 9 / 14

Operations on Regular Languages Let A and B be languages. We define regular operations union, concatenation, and start as follows Union: A B = {x x A x B} Concatenation: A B = {xy x A y B} Star: A = {x 1...x k k 0 x i A, 0 i k} Note: 1. ɛ A, no matter what A is 2. A + denotes A A 10 / 14

Regular Expressions A regular expression (RE in short) is a string of symbols that describes a regular language. Three base cases: For any a Σ, a is a regular expression denoting the language {a} ɛ is a regular expression denoting the language {ɛ} is a regular expression denoting the language ; Three recursive cases: If r 1 and r 2 are regular expressions denoting languages L 1 and L 2, respectively, then Union: r 1 r 2 denotes L 1 L 2 Concatenation: r 1 r 2 denotes L 1 L 2 Star: r 1 denotes L 1 11 / 14

Some useful notation Let r be a regular expression: The string r + represents rr, and it also holds that r + {ɛ} = r The string r k represents rr...r }{{} k times Recall that the symbol Σ represents the alphabet {a 1,..., a k } As with automata, the language represented by r is denoted L (r) 12 / 14

Precedence Rules The star ( ) operation has the highest precedence The concatenation ( ) operation is second on precedence order The union ( ) or (+) operation is the least preferred Parenthesis can be omitted using these rules 13 / 14

Examples 0 10 = 14 / 14

Examples 0 10 = {w w contains a single 1} Σ 1Σ = 14 / 14

Examples 0 10 = {w w contains a single 1} Σ 1Σ = {w w has at least a single 1} Σ (101)Σ = 14 / 14

Examples 0 10 = {w w contains a single 1} Σ 1Σ = {w w has at least a single 1} Σ (101)Σ = {w w contains 101 as a substring} 1 (01 + ) = 14 / 14

Examples 0 10 = {w w contains a single 1} Σ 1Σ = {w w has at least a single 1} Σ (101)Σ = {w w contains 101 as a substring} 1 (01 + ) = {w every 0 in w is followed by at least a single 1} (ΣΣ) = 14 / 14

Examples 0 10 = {w w contains a single 1} Σ 1Σ = {w w has at least a single 1} Σ (101)Σ = {w w contains 101 as a substring} 1 (01 + ) = {w every 0 in w is followed by at least a single 1} (ΣΣ) = {w w is of even length} 0Σ 0 1Σ 1 0 1 14 / 14

Examples 0 10 = {w w contains a single 1} Σ 1Σ = {w w has at least a single 1} Σ (101)Σ = {w w contains 101 as a substring} 1 (01 + ) = {w every 0 in w is followed by at least a single 1} (ΣΣ) = {w w is of even length} 0Σ 0 1Σ 1 0 1 all words starting and ending with the same letter (0 ɛ)1 = 01 1 14 / 14

Examples 0 10 = {w w contains a single 1} Σ 1Σ = {w w has at least a single 1} Σ (101)Σ = {w w contains 101 as a substring} 1 (01 + ) = {w every 0 in w is followed by at least a single 1} (ΣΣ) = {w w is of even length} 0Σ 0 1Σ 1 0 1 all words starting and ending with the same letter (0 ɛ)1 = 01 1 all strings of forms 1,11,1...1 and 0,1,11,1...1 R 14 / 14

Examples 0 10 = {w w contains a single 1} Σ 1Σ = {w w has at least a single 1} Σ (101)Σ = {w w contains 101 as a substring} 1 (01 + ) = {w every 0 in w is followed by at least a single 1} (ΣΣ) = {w w is of even length} 0Σ 0 1Σ 1 0 1 all words starting and ending with the same letter (0 ɛ)1 = 01 1 all strings of forms 1,11,1...1 and 0,1,11,1...1 R 14 / 14

Examples 0 10 = {w w contains a single 1} Σ 1Σ = {w w has at least a single 1} Σ (101)Σ = {w w contains 101 as a substring} 1 (01 + ) = {w every 0 in w is followed by at least a single 1} (ΣΣ) = {w w is of even length} 0Σ 0 1Σ 1 0 1 all words starting and ending with the same letter (0 ɛ)1 = 01 1 all strings of forms 1,11,1...1 and 0,1,11,1...1 R {ɛ} 14 / 14