Computability Review homework. Regular Operations. Nondeterministic machines. NFSM = FSM Homework: By hand, build FSM version of specific NFSM. Try to.

Slides:



Advertisements
Similar presentations
Chapter Three: Closure Properties for Regular Languages
Advertisements

CSE 311 Foundations of Computing I
1 1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 3 School of Innovation, Design and Engineering Mälardalen University 2012.
Pushdown Automata Chapter 12. Recognizing Context-Free Languages Two notions of recognition: (1) Say yes or no, just like with FSMs (2) Say yes or no,
Pushdown Automata Chapter 12. Recognizing Context-Free Languages We need a device similar to an FSM except that it needs more power. The insight: Precisely.
Basic Structures: Sets, Functions, Sequences, Sums, and Matrices
January 7, 2015CS21 Lecture 21 CS21 Decidability and Tractability Lecture 2 January 7, 2015.
Pushdown Automata Part II: PDAs and CFG Chapter 12.
CS21 Decidability and Tractability
Introduction to Computability Theory
NFAs Sipser 1.2 (pages 47–54). CS 311 Mount Holyoke College 2 Recall… Last time we showed that the class of regular languages is closed under: –Complement.
Lecture 3UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 3.
1 FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY (For next time: Read Chapter 1.3 of the book)
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.
Automata & Formal Languages, Feodor F. Dragan, Kent State University 1 CHAPTER 1 Regular Languages Contents Finite Automata (FA or DFA) definitions, examples,
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Nondeterminism.
CS5371 Theory of Computation Lecture 6: Automata Theory IV (Regular Expression = NFA = DFA)
CS5371 Theory of Computation Lecture 4: Automata Theory II (DFA = NFA, Regular Language)
FSA Lecture 1 Finite State Machines. Creating a Automaton  Given a language L over an alphabet , design a deterministic finite automaton (DFA) M such.
Introduction to Finite Automata Adapted from the slides of Stanford CS154.
Finite State Machines Data Structures and Algorithms for Information Processing 1.
Formal Language Finite set of alphabets Σ: e.g., {0, 1}, {a, b, c}, { ‘{‘, ‘}’ } Language L is a subset of strings on Σ, e.g., {00, 110, 01} a finite language,
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
REGULAR LANGUAGES.
1 Unit 1: Automata Theory and Formal Languages Readings 1, 2.2, 2.3.
Regular Expressions and Finite State Automata  Themes  Finite State Automata (FSA)  Describing patterns with graphs  Programs that keep track of state.
Theory of Computation, Feodor F. Dragan, Kent State University 1 Regular expressions: definition An algebraic equivalent to finite automata. We can build.
Introduction to CS Theory Lecture 3 – Regular Languages Piotr Faliszewski
1 111 Computability, etc. Midterm review. Turing machines. Finite state machines. Push down automata. Homework: FSA, PDA, TM problems (can work in teams)
Automata, Computability, & Complexity by Elaine Rich ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Slides provided by author Slides edited for.
Computabilty Computability Finite State Machine. Regular Languages. Homework: Finish Craps. Next Week: On your own: videos +
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 3 Mälardalen University 2010.
Regular Expressions Chapter 6 1. Regular Languages Regular Language Regular Expression Finite State Machine L Accepts 2.
CHAPTER 1 Regular Languages
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 11 Midterm Exam 2 -Context-Free Languages Mälardalen University 2005.
CompSci 102 Discrete Math for Computer Science
Copyright © Curt Hill Finite State Automata Again This Time No Output.
Context-Free and Noncontext-Free Languages Chapter 13 1.
Formal Definition of Computation Let M = (Q, ∑, δ, q 0, F) be a finite automaton and let w = w 1 w w n be a string where each wi is a member of the.
Chapter 2 With Question/Answer Animations. Section 2.1.
CS 208: Computing Theory Assoc. Prof. Dr. Brahim Hnich Faculty of Computer Sciences Izmir University of Economics.
Regular Expressions Chapter 6. Regular Languages Regular Language Regular Expression Finite State Machine L Accepts.
CS 203: Introduction to Formal Languages and Automata
Recognising Languages We will tackle the problem of defining languages by considering how we could recognise them. Problem: Is there a method of recognising.
Computability Regular expressions. Languages defined by regular expresses = Regular languages (languages recognized by FSM). Applications. Pumping lemma.
Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1 Chapter 1 Regular Languages Some slides are in courtesy.
UNIT - I Formal Language and Regular Expressions: Languages Definition regular expressions Regular sets identity rules. Finite Automata: DFA NFA NFA with.
Computability Review homework. Video. Variations. Definitions. Enumerators. Hilbert's Problem. Algorithms. Summary Homework: Give formal definition of.
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen.
Regular Languages Chapter 1 Giorgi Japaridze Theory of Computability.
Complexity and Computability Theory I Lecture #5 Rina Zviel-Girshin Leah Epstein Winter
Pushdown Automata Chapter 12. Recognizing Context-Free Languages Two notions of recognition: (1) Say yes or no, just like with FSMs (2) Say yes or no,
MA/CSSE 474 Theory of Computation How many regular/non-regular languages are there? Closure properties of Regular Languages (if there is time) Pumping.
Week 14 - Friday.  What did we talk about last time?  Simplifying FSAs  Quotient automata.
1 Advanced Theory of Computation Finite Automata with output Pumping Lemma Theorem.
Regular Languages, Regular Operations, Closure
Theory of Computation Lecture 22: Turing Machines III
Hierarchy of languages
COSC 3340: Introduction to Theory of Computation
CSE 311: Foundations of Computing
Finite Automata Reading: Chapter 2.
Chapter Five: Nondeterministic Finite Automata
MA/CSSE 474 Theory of Computation Nondeterminism NFSMs.
CSE 311 Foundations of Computing I
Chapter 1 Regular Language
Finite-State Machines with No Output
LECTURE # 07.
CHAPTER 1 Regular Languages
Theory of Computation Lecture 23: Turing Machines III
Presentation transcript:

Computability Review homework. Regular Operations. Nondeterministic machines. NFSM = FSM Homework: By hand, build FSM version of specific NFSM. Try to think of a language that is not a regular language.

Q&A video problems? Discussion

Regular operations Suppose we have 2 languages A and B –remember these are sets. They may be infinite, that is, defined by patterns… More on this later. Consider the following languages –A union B (A ⊔B) : all strings in either A or B –A concatenate B (A ⃘ B or AB): all strings made up of a string in A followed by a string in B. Note: may include all of A and/or all of B depending on whether or not the empty string is in B or in A. –A*: finite strings in A, concatenated together

Aside Generally, thinking about these logical, formal definitions, proofs, constructions, improves programming skills. Specifically, important in considering a problem to think about finiteness,memory, states, etc.

Examples Let the alphabet be: {a, b, c, d, e}. Let A by the language consists of all strings with only a's {a, aa, aaa….} and B the language consisting of strings with only b's {b, bb, bbb, …}. What is A ⊔B ? What is AB ? Trick question: what is A* ?

Examples (from book) A is {good, bad}. B is {boy, girl} What is A*? What is B*? What is A ⊔B ? What is AB? What is BA? What is ( A ⊔B)* ?

Method We can (and will) prove that if A and B are regular languages, then so are A union B, AB, and A* We say the class of regular languages is closed under the union operation, concatenate operation and star operation. From the machine M that accepts A and N that accepts B, build/design/specify machines for those 3 languages.

General method for proving for union If our machine could scan the input twice, we would be done! Instead, simulate scanning it twice (by each of M and N) by keeping track of what would have happened using each machine.

Proof for union Construct a new machine with states defined as pairs, one from M and one from N. –formal math. term: cartesian product Initial state (Ms1, Ns1). Transition function: if in M, state s, letter a went to Mt and in N, state v, letter a went to Nw, then in the new machine (Ms,Nv) reading a goes to (Mt,Nw) Final states: all states in which at least one of the two are final. –F={(m,n) | m ∊M final or n ∊ N final }

Need to do concatenation and star… Instead of tackling this directly, make a diversion, which will make these proofs easier….

New type of machine: Nondeterministic FSM Add non-determinism to transition table State s reading symbol a can go to 0, 1 or more different states. There also can be empty/free links between states: symbol ∊. –Think of this as trying alternate paths, guesses, parallel processes. A string is accepted if there is at least one set of choices, one path that leads from the start state to an accepting state. Will give examples and then surprise!

piece of graph 0 e1 1 0

Example Alphabet {English alphabet plus _} Build a NDFSM that accepts any string in which some where in the string there occurs "GOOD_JOB". Initial state: I StateG, StateO1,StateO2,StateD,Date_,StateJ,StateO3,StateB. Transitions: All letters go from I to itself plus I on letter G to StateG, StateG on letter O to StateO1, …. StateB: all letters to itself. StateB is accepting state. Think: system tries all possibilities. Only one has to work for starting off with the G. Note: If there isn't a transition, then nothing happens. Machine stays in that state. Does this work?

General example Building a machine to accept languages A ⊔B, given M that accepts A and N that accepts B Take M and N and combine (overlay) the initial states. From the initial state have all the possibilities, going off to the two machines… A string is accepted if there is a path to one of the finite states. This NDFSM has less states than the one with the cartesian product.

Surprise For every NFSM, we can design a FSM that does the same thing! So, the non-determinism don't really add more capability. Paradox: since every FSM is a NFSM, it seems that there are more NFSM. But for every NFSM, there is a FSM that does the same thing!!!! Since the numbers of FSM and NFSM are infinite, can't make arguments made for finite sets.

Rough analogy In programming languages, switch statements are nice! However, everything you can do with a switch statement, you can do with (combinations of) if statements.

Why bother with nondeterminism? It can be easier to prove certain things with NFSM. –see A ⊔B example! Even easier for AB case. Generally speaking, the NDFSM will have smaller number of states.

Proof that for every NDFSM there is a FSM that does the same job Similar to method for union, in which we kept track of the possibilities using the paired states (cartesian product). Given the NDFSM. Construct a FSM with states the set of all subsets of the states of the NDFSM. So if the NDFSM had states: S1, S2, S3…Sn, the FSM will have states corresponding to the subsets. We use those names for the names of the (new) states. {Ssi,sj,sk…sq | si,sj, sk,…sq are states in NDFSM} The list of subsets is finite. It may be large, in fact, if N is the number of states in the NDFSM, then 2 N is the number of subsets.

Subset example Set {a,b,c}, write the subsets. I'll start off by writing two subsets: the empty set and the set {a, b, c} ? How many?

Proof NDFSM can be replaced by a FSM Transition: make a transition from state subsetX to state subsetY on letter a if there is a transition on a from any member of subsetX to any member of subsetY Final states: states in which at least one member of the subset is a final state. Claim: if there was a path in the NDFSM to a final state, there will be a path in the constructed FSM to a final state.

Proof that a FSM exists to accept the language AB, if A and B each have FSMs Have FSM M accepting A and N accepting B. We can build a NDFSM to accept AB. The states are the union of the two sets of states. The starting state is the starting state of M. The accepting states are the accepting states of N. Add transitions using the empty string ∊ from the accepting states of M to the initial state of N. Claim: this does it!

Exercise Build (design) a NDFSM to accept A*.

Terminology The set of languages accepted by FSM are called the regular languages. The set of regular languages is closed with respect to union, concatenation and star. –Proof: union done directly, concatenation done using NSFSM, star left to you! We can use NDFSM in place of FSM for proofs (proof by construction).

Regular expressions These are used in programming to define acceptable sets fitting some pattern using a specific, fixed way of writing patterns. What are the ways? –you can specify a finite set of strings. –if R and Q are regular expressions, then R concatenated with Q means any string in R concatenated with any string in Q. –if R and Q are regular expressions, you can specify the union to be a regular expression. –if R is a regular expression, then you can specify * operator over R, meaning concatenation of any (finite) number of elements in R.

Examples over alphabet {0,1} (0,1) This is a regular expression defining a language with exactly 2 members. This also could be written (0 UNION 1). (0 UNION 1)* This is the language of all possible strings holding 0s and 1s, including the empty string. (1)* This is the language of any number of 1s including no 1s, that is, the empty string, also indicated by ∊. 1

Examples What is a regular expression for social security numbers? What is a regular expression for addresses? – addresses for people at Purchase College

Homework Complete proofs. Invent more examples. Think of a language for which there does not exact a FSM. Next class: –regular expressions –Languages defined by a regular expression ARE regular languages One direction: from regular expression, build the FSM (or NDFSM) Other direction: from a FSM, produce the regular expression –Pumping lemma (way to prove something is NOT a regular language) –Uses of FSM