Theory of Languages and Automata

Similar documents
Language properties and Grammar of Parallel and Series Parallel Languages

A General Class of Noncontext Free Grammars Generating Context Free Languages

Informatics 2A: Language Complexity and the. Inf2A: Chomsky Hierarchy

Lecture 10: Reinforcement Learning

COMPUTATIONAL COMPLEXITY OF LEFT-ASSOCIATIVE GRAMMAR

Erkki Mäkinen State change languages as homomorphic images of Szilard languages

A R "! I,,, !~ii ii! A ow ' r.-ii ' i ' JA' V5, 9. MiN, ;

On the Polynomial Degree of Minterm-Cyclic Functions

Proof Theory for Syntacticians

Grammars & Parsing, Part 1:

Are You Ready? Simplify Fractions

CS 598 Natural Language Processing

Classroom Connections Examining the Intersection of the Standards for Mathematical Content and the Standards for Mathematical Practice

Language Evolution, Metasyntactically. First International Workshop on Bidirectional Transformations (BX 2012)

Enumeration of Context-Free Languages and Related Structures

A Version Space Approach to Learning Context-free Grammars

AP Calculus AB. Nevada Academic Standards that are assessable at the local level only.

Discriminative Learning of Beam-Search Heuristics for Planning

AGS THE GREAT REVIEW GAME FOR PRE-ALGEBRA (CD) CORRELATED TO CALIFORNIA CONTENT STANDARDS

Lecture 1: Machine Learning Basics

Grade 5 + DIGITAL. EL Strategies. DOK 1-4 RTI Tiers 1-3. Flexible Supplemental K-8 ELA & Math Online & Print

Morphotactics as Tier-Based Strictly Local Dependencies

Probability and Game Theory Course Syllabus

RANKING AND UNRANKING LEFT SZILARD LANGUAGES. Erkki Mäkinen DEPARTMENT OF COMPUTER SCIENCE UNIVERSITY OF TAMPERE REPORT A ER E P S I M S

Pre-Algebra A. Syllabus. Course Overview. Course Goals. General Skills. Credit Value

Mathematics Success Level E

arxiv: v1 [math.at] 10 Jan 2016

have to be modeled) or isolated words. Output of the system is a grapheme-tophoneme conversion system which takes as its input the spelling of words,

IT Students Workshop within Strategic Partnership of Leibniz University and Peter the Great St. Petersburg Polytechnic University

Cal s Dinner Card Deals

Grade 6: Correlated to AGS Basic Math Skills

Backwards Numbers: A Study of Place Value. Catherine Perez

Evolution of Collective Commitment during Teamwork

Liquid Narrative Group Technical Report Number

Natural Language Processing. George Konidaris

CS 1103 Computer Science I Honors. Fall Instructor Muller. Syllabus

Shockwheat. Statistics 1, Activity 1

Introduction to Causal Inference. Problem Set 1. Required Problems

The New York City Department of Education. Grade 5 Mathematics Benchmark Assessment. Teacher Guide Spring 2013

systems have been developed that are well-suited to phenomena in but is properly contained in the indexed languages. We give a

Statewide Framework Document for:

Outreach Connect User Manual

NCU IISR English-Korean and English-Chinese Named Entity Transliteration Using Different Grapheme Segmentation Approaches

The Evolution of Random Phenomena

TOPICS LEARNING OUTCOMES ACTIVITES ASSESSMENT Numbers and the number system

Refining the Design of a Contracting Finite-State Dependency Parser

The Indices Investigations Teacher s Notes

Objectives. Chapter 2: The Representation of Knowledge. Expert Systems: Principles and Programming, Fourth Edition

ARNE - A tool for Namend Entity Recognition from Arabic Text

College Pricing and Income Inequality

Teaching a Laboratory Section

Presentation skills. Bojan Jovanoski, project assistant. University Skopje Business Start-up Centre

Corrective Feedback and Persistent Learning for Information Extraction

Syntax Parsing 1. Grammars and parsing 2. Top-down and bottom-up parsing 3. Chart parsers 4. Bottom-up chart parsing 5. The Earley Algorithm

Page 1 of 11. Curriculum Map: Grade 4 Math Course: Math 4 Sub-topic: General. Grade(s): None specified

Edexcel GCSE. Statistics 1389 Paper 1H. June Mark Scheme. Statistics Edexcel GCSE

Math 96: Intermediate Algebra in Context

Mathematics subject curriculum

Math 098 Intermediate Algebra Spring 2018

"f TOPIC =T COMP COMP... OBJ

School Competition and Efficiency with Publicly Funded Catholic Schools David Card, Martin D. Dooley, and A. Abigail Payne

TabletClass Math Geometry Course Guidebook

Visual CP Representation of Knowledge

Improving Fairness in Memory Scheduling

CS 101 Computer Science I Fall Instructor Muller. Syllabus

Introduction to Simulation

Entrepreneurial Discovery and the Demmert/Klein Experiment: Additional Evidence from Germany

THE UNIVERSITY OF SYDNEY Semester 2, Information Sheet for MATH2068/2988 Number Theory and Cryptography

PHYSICS 40S - COURSE OUTLINE AND REQUIREMENTS Welcome to Physics 40S for !! Mr. Bryan Doiron

Action Models and their Induction

2/15/13. POS Tagging Problem. Part-of-Speech Tagging. Example English Part-of-Speech Tagsets. More Details of the Problem. Typical Problem Cases

Disambiguation of Thai Personal Name from Online News Articles

Foothill College Fall 2014 Math My Way Math 230/235 MTWThF 10:00-11:50 (click on Math My Way tab) Math My Way Instructors:

Functional Skills Mathematics Level 2 assessment

University of Cincinnati College of Medicine. DECISION ANALYSIS AND COST-EFFECTIVENESS BE-7068C: Spring 2016

Factoring - Grouping

MTH 141 Calculus 1 Syllabus Spring 2017

Detecting English-French Cognates Using Orthographic Edit Distance

AMULTIAGENT system [1] can be defined as a group of

Learning Structural Correspondences Across Different Linguistic Domains with Synchronous Neural Language Models

PRODUCT PLATFORM DESIGN: A GRAPH GRAMMAR APPROACH

Outline for Session III

A Grammar for Battle Management Language

Paper 2. Mathematics test. Calculator allowed. First name. Last name. School KEY STAGE TIER

Should a business have the right to ban teenagers?

What the National Curriculum requires in reading at Y5 and Y6

Transfer Learning Action Models by Measuring the Similarity of Different Domains

A process by any other name

An Introduction to Simio for Beginners

Speech Segmentation Using Probabilistic Phonetic Feature Hierarchy and Support Vector Machines

Stacks Teacher notes. Activity description. Suitability. Time. AMP resources. Equipment. Key mathematical language. Key processes

MOODLE 2.0 GLOSSARY TUTORIALS

Reinforcement Learning by Comparing Immediate Reward

Extending Place Value with Whole Numbers to 1,000,000

Guide to the Uniform mark scale (UMS) Uniform marks in A-level and GCSE exams

Planning with External Events

Radius STEM Readiness TM

GACE Computer Science Assessment Test at a Glance

CALCULUS III MATH

Pre-AP Geometry Course Syllabus Page 1

Transcription:

Theory of Languages and Automata Chapter 1- Regular Languages & Finite State Automaton Sharif University of Technology

Finite State Automaton O We begin with the simplest model of Computation, called finite state machine or finite automaton. O are good models for computers with an extremely limited amount of memory. Embedded Systems O Markov Chains are the probabilistic counterpart of Finite Automata Theory of Languages and Automata Prof. Movaghar 2

Simple Example O Automatic door Door Theory of Languages and Automata Prof. Movaghar 3

Simple Example (cont.) O State Diagram O State Transition Table Neither Front Rear Both Closed Closed Open Closed Closed Open Closed Open Open Open Theory of Languages and Automata Prof. Movaghar 4

Formal Definition O A finite automaton is a 5-tuple (Q,Σ,δ,q 0, F), where 1. Q is a finite set called states, 2. Σ is a finite set called the alphabet, 3. δ : Q Σ Q is the transition function, 4. q 0 Q is the start state, and 5. F Q is the set of accept states. Theory of Languages and Automata Prof. Movaghar 5

Example O M 1 = (Q, Σ, δ, q 0, F), where 1. Q = {q 1, q 2, q 3 }, 2. Σ = {0,1}, 3. δ is described as q 1 q 1 q 2 q 2 q 3 q 2 q 3 q 2 q 2 1. q 1 is the start state, and 2. F = {q 2 }. 0 1 Theory of Languages and Automata Prof. Movaghar 6

Language of a Finite machine O If A is the set of all strings that machine M accepts, we say that A is the language of machine M and write: L(M) = A. We say that M recognizes A or that M accepts A. Theory of Languages and Automata Prof. Movaghar 7

Example O L(M 1 ) = {w w contains at least one 1 and even number of 0s follow the last 1}. Theory of Languages and Automata Prof. Movaghar 8

Example O M 4 accepts all strings that start and end with a or with b. Theory of Languages and Automata Prof. Movaghar 9

Formal Definition O M = (Q, Σ, δ, q 0, F) O w = w 1 w 2 w n i, w i Σ O M accepts w r 0, 1 r,, n r 1. r 0 = q 0, i, r i Q 2. δ(r i, w i+1 ) = i+1 r, for i = 0,, n-1, 3. r n F. Theory of Languages and Automata Prof. Movaghar 10

Regular Language O A language is called a regular language if some finite automaton recognizes it. Theory of Languages and Automata Prof. Movaghar 11

Example O L (M 5 ) = {w the sum of the symbols in w is 0 modulo 3, except that <RESET> resets the count to 0}. As M 5 recognizes this language, it is a regular language. Theory of Languages and Automata Prof. Movaghar 12

Designing Finite Automata O Put yourself in the place of the machine and then see how you would go about performing the machine s task. O Design a finite automaton to recognize the regular language of all strings that contain the string 001 as a substring. Theory of Languages and Automata Prof. Movaghar 13

Designing Finite Automata (cont.) O There are four possibilities: You 1. haven t just seen any symbols of the pattern, 2. have just seen a 0, 3. have just seen 00, or 4. have seen the entire pattern 001. Theory of Languages and Automata Prof. Movaghar 14

The Regular Operations O Let A and B be languages. We define the regular operations union, concatenation, and star as follows. O Union: A B = {x x A or x B}. O Concatenation: A B = {xy x A and y B }. O Star: A * = {x 1 x 2 x k k 0 and each x i A }. Theory of Languages and Automata Prof. Movaghar 15

Closure Under Union O THEOREM The class of regular languages is closed under the union operation. Theory of Languages and Automata Prof. Movaghar 16

Proof O Let M 1 = (Q 1, Σ 1, δ 1, q 1, F 1 ) recognize A 1, and M 2 = (Q 2, Σ 2, δ 2, q 2, F 2 ) recognize A 2. O Construct M = (Q, Σ, δ, q 0, F) to recognize A 1 A 2. 1. Q = Q 1 Q 2 2. Σ = Σ 1 Σ 2 3. δ((r 1,r 2 ),a) = (δ 1 (r 1,a), δ 2 (r 2,a)). 4. q 0 is the pair (q 1, q 2 ). 5. F is the set of pair in which either members in an accept state of M 1 or M 2. F = (F 1 Q 2 ) (Q 1 F 2 ) F F 1 F 2 Theory of Languages and Automata Prof. Movaghar 17

Closure under Concatenation O THEOREM The class of regular languages is closed under the concatenation operation. O To prove this theorem we introduce a new technique called nondeterminism. Theory of Languages and Automata Prof. Movaghar 18

Nondeterminism O In a nondeterministic machine, several choices may exit for the next state at any point. O Nondeterminism is a generalization of determinism, so every deterministic finite automaton is automatically a nondeterministic finite automaton. Theory of Languages and Automata Prof. Movaghar 19

Differences between DFA & NFA O First, very state of a DFA always has exactly one exiting transition arrow for each symbol in the alphabet. In an NFA a state may have zero, one, or more exiting arrows for each alphabet symbol. O Second, in a DFA, labels on the transition arrows are symbols from the alphabet. An NFA may have arrows labeled with members of the alphabet or ε. Zero, one, or many arrows may exit from each state with the label ε. Theory of Languages and Automata Prof. Movaghar 20

Deterministic vs. Nondeterministic Theory of Languages and Automata Prof. Movaghar 21

Example O Consider the computation of N 1 on input 010110. Theory of Languages and Automata Prof. Movaghar 22

Example (cont.) Theory of Languages and Automata Prof. Movaghar 23

Formal Definition O A nondeterministic finite automaton is a 5-tuple (Q,Σ,δ,q 0, F), where 1. Q is a finite set of states, 2. Σ is a finite alphabet, 3. δ : Q Σ ε P(Q) is the transition function, 4. q 0 Q is the start state, and 5. F Q is the set of accept states. Theory of Languages and Automata Prof. Movaghar 24

Example O N 1 = (Q, Σ, δ, q 0, F), where 1. Q = {q 1, q 2, q 3, q 4 }, 2. Σ = {0,1}, 3. δ is given as 0 1 ε q 1 {q 1 } {q 1,q 2 } q 2 {q 3 } {q 4 } q 3 {q 4 } q 4 {q 4 } {q 4 } 1. q 1 is the start state, and 2. F = {q 4 }. Theory of Languages and Automata Prof. Movaghar 25

Equivalence of NFAs & DFAs O THEOREM Every nondeterministic finite automaton has an equivalent deterministic finite automaton. O PROOF IDEA convert the NFA into an equivalent DFA that simulates the NFA. If k is the number of states of the NFA, so the DFA simulating the NFA will have 2 k states. Theory of Languages and Automata Prof. Movaghar 26

Proof O Let N = (Q,Σ,δ,q 0, F) be the NFA recognizing A. We construct a DFA M =(Q',Σ',δ',q 0 ', F ) recognizing A. O let's first consider the easier case wherein N has no ε arrows. 1. Q' = P(Q). 2. 3. q 0 = q 0. 4. F' = {R Q R contains an accept state of N}. Theory of Languages and Automata Prof. Movaghar 27

Proof (cont.) O Now we need to consider the ε arrows. O for R Q let O E(R) = {q q can be reached from R by traveling along 0 or more ε arrows}. 1. Q' = P(Q). 2. δ' (R,a) ={q Q q E(δ(r,a)) for some r R}. 3. q 0 = E({q 0 }). 4. F' = {R Q R contains an accept state of N}. Theory of Languages and Automata Prof. Movaghar 28

Corollary O A language is regular if and only if some nondeterministic finite automaton recognizes it. Theory of Languages and Automata Prof. Movaghar 29

Example O D s state set is {,{1},{2},{3},{1,2},{1,3},{2,3},{1,2,3}}. O The start state is E({1}) = {1,3}. O The accept states are {{1},{1,2},{1,3},{1,2,3}}. Theory of Languages and Automata Prof. Movaghar 30

Example (cont.) After removing unnecessary states Theory of Languages and Automata Prof. Movaghar 31

CLOSURE UNDER THE REGULAR OPERATIONS [Using NFA] Theory of Languages and Automata Prof. Movaghar 32

Closure Under Union O The class of regular languages is closed under the Union operation. Let NFA1 recognize A1 and NFA2 recognize A2. Construct NFA3 to recognize A1 U A2. Theory of Languages and Automata Prof. Movaghar 33

Proof (cont.) Theory of Languages and Automata Prof. Movaghar 34

Closure Under Concatenation Operation O The class of regular languages is closed under the concatenation operation. Theory of Languages and Automata Prof. Movaghar 35

Proof (cont.) Theory of Languages and Automata Prof. Movaghar 36

Closure Under Star operation O The class of regular languages is closed under the star operation. O We represent another NFA to recognize A*. Theory of Languages and Automata Prof. Movaghar 37

O Proof (cont.) Theory of Languages and Automata Prof. Movaghar 38

Regular Expression O Circular Definition? Theory of Languages and Automata Prof. Movaghar 39

Regular Expression Language O Theory of Languages and Automata Prof. Movaghar 40

Examples(cont.) O Theory of Languages and Automata Prof. Movaghar 41

Equivalence of DFA and Regular Expression O A language is regular if and only if some regular expression describes it. Lemma: O If a language is described by a regular expression, then it is regular. O If a language is regular, then it is described by a regular expression. Theory of Languages and Automata Prof. Movaghar 42

Building an NFA from the Regular Expression O We consider the six cases in the formal definition of regular expressions Theory of Languages and Automata Prof. Movaghar 43

Examples Theory of Languages and Automata Prof. Movaghar 44

Other direction of the proof O We need to show that, if a language A is regular, a regular expression describes it! O First we show how to convert DFAs into GNFAs, and then GNFAs into regular expressions. O We can easily convert a DFA into a GNFA in the special form. Theory of Languages and Automata Prof. Movaghar 45

Formal Definition O Theory of Languages and Automata Prof. Movaghar 46

Assumptions For convenience we require that GNFAs always have a special form that meets the following conditions: 1. The start state has transition arrows going to every other state but no arrows coming in from any other state. 2. There is only a single accept state, and it has arrows coming in from every other state but no arrows going to any other state. Furthermore, the accept state is not the same as the start state. 3. Except for the start and accept states, one arrow goes from every state to every other state and also from each state to itself. Theory of Languages and Automata Prof. Movaghar 47

Acceptance of Languages for GNFA O A GNFA accepts a string w in Σ* if w = w 1 w 2 w k, where each w i is in Σ* is in Σ* and a sequence of q 0, q 1,, q k exists such that 1. q 0 = q start is the start state, 2. q k = q accept is the accept state, and 3. For each i, we have w i L(R i ) where R i = δ(q i-1, q i ); in other words R i is the expression on the arrow from q i-1 to q i.

How to Eliminate a State? Theory of Languages and Automata Prof. Movaghar 49

Example Theory of Languages and Automata Prof. Movaghar 50

Example Theory of Languages and Automata Prof. Movaghar 51

Grammar O A grammar G is a 4-tuple G = (V, Σ, R, S) where: 1. V is a finite set of variables, 2. Σ is a finite, disjoint from V, of terminals, 3. R is a finite set of rules, 4. S is the start variable. Theory of Languages and Automata Prof. Movaghar 52

O Rule Theory of Languages and Automata Prof. Movaghar 53

Derivation O Theory of Languages and Automata Prof. Movaghar 54

Language of a Grammar O Theory of Languages and Automata Prof. Movaghar 55

OExample Theory of Languages and Automata Prof. Movaghar 56

A Notation for Grammars Consider the grammar G = ({S}, {a,b}, P, S} with P given by S asb S ε The above grammar is usually written as: G: S asb ε Theory of Languages and Automata Prof. Movaghar 57

Regular Grammar A grammar G = (V, Σ, R, S) is said to be right-linear if all rules are of the form A xb A x Where A, B V, and X Σ*. A grammar is said to be leftlinear if all rules are of the form A Bx A x A regular grammar is one that is either right-linear or left-linear. Theory of Languages and Automata Prof. Movaghar 58

Theorem Let G = (V, Σ, R, S) be a right-linear grammar. Then: L(G) is a regular language. Theory of Languages and Automata Prof. Movaghar 59

Example Construct a NFA that accepts the language generated by the grammar V 0 av 1 V 1 abv 0 b V 0 a V 1 b V f b a V 2 Theory of Languages and Automata Prof. Movaghar 60

Theorem Let L be a regular language on the alphabet Σ. Then: There exists a right-linear grammar G = (V, Σ, R, S) Such that L = L(G). Theory of Languages and Automata Prof. Movaghar 61

Theorem Theorem A language is regular if and only if there exists a left-linear grammar G such that L = L(G). Outline of the proof: Given any left-linear grammar with rules of the form A Bx A x We can construct a right-linear Ĝ by replacing every such rule of G with A x R B A x R We have L(G) = L(Ĝ) R. Theory of Languages and Automata Prof. Movaghar 62

Theorem O Theory of Languages and Automata Prof. Movaghar 63