COMS 3261, Lecture 2 Strings, Languages, Automata September 6, 2001.

Slides:



Advertisements
Similar presentations
Recognising Languages We will tackle the problem of defining languages by considering how we could recognise them. Problem: Is there a method of recognising.
Advertisements

Recognising Languages We will tackle the problem of defining languages by considering how we could recognise them. Problem: Is there a method of recognising.
CSE 311 Foundations of Computing I
4b Lexical analysis Finite Automata
Nondeterministic Finite Automata CS 130: Theory of Computation HMU textbook, Chapter 2 (Sec 2.3 & 2.5)
CSE 311: Foundations of Computing Fall 2013 Lecture 23: Finite state machines and minimization.
Chapter Two: Finite Automata
1 Languages. 2 A language is a set of strings String: A sequence of letters Examples: “cat”, “dog”, “house”, … Defined over an alphabet: Languages.
CS21 Decidability and Tractability
1 Introduction to Computability Theory Lecture3: Regular Expressions Prof. Amos Israeli.
Finite Automata Great Theoretical Ideas In Computer Science Anupam Gupta Danny Sleator CS Fall 2010 Lecture 20Oct 28, 2010Carnegie Mellon University.
1 Introduction to Computability Theory Lecture4: Regular Expressions Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture3: Regular Expressions Prof. Amos Israeli.
CS5371 Theory of Computation
Finite Automata Finite-state machine with no output. FA consists of States, Transitions between states FA is a 5-tuple Example! A string x is recognized.
1 Languages and Finite Automata or how to talk to machines...
Automata & Formal Languages, Feodor F. Dragan, Kent State University 1 CHAPTER 1 Regular Languages Contents Finite Automata (FA or DFA) definitions, examples,
CS5371 Theory of Computation Lecture 1: Mathematics Review I (Basic Terminology)
Lecture 3 Goals: Formal definition of NFA, acceptance of a string by an NFA, computation tree associated with a string. Algorithm to convert an NFA to.
1 Intro to Finite Automata Chapter 2 introduces the concept of a Finite Automata (or FA). An FA has several properties: It is theoretical. It allows computer.
Finite Automata Chapter 5. Formal Language Definitions Why need formal definitions of language –Define a precise, unambiguous and uniform interpretation.
Topics Automata Theory Grammars and Languages Complexities
CSC 361Finite Automata1. CSC 361Finite Automata2 Formal Specification of Languages Generators Grammars Context-free Regular Regular Expressions Recognizers.
Introduction to Finite Automata Adapted from the slides of Stanford CS154.
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
1 Non-Deterministic Finite Automata. 2 Alphabet = Nondeterministic Finite Automaton (NFA)
Finite State Machines Data Structures and Algorithms for Information Processing 1.
Great Theoretical Ideas in Computer Science.
Rosen 5th ed., ch. 11 Ref: Wikipedia
Functions Definition & purpose Notation Functions on binary / returning binary values Finite automaton model We haven’t completely left the world of counting.
Finite State Automata: A Brief Introduction CSE 260 / CMPSC 360 Doug Hogan Penn State University.
CMPS 3223 Theory of Computation
Lecture 23: Finite State Machines with no Outputs Acceptors & Recognizers.
CSCI 2670 Introduction to Theory of Computing September 28, 2005.
INTRODUCTION TO THE THEORY OF COMPUTATION INTRODUCTION MICHAEL SIPSER, SECOND EDITION 1.
Lecture 05: Theory of Automata:08 Kleene’s Theorem and NFA.
4b 4b Lexical analysis Finite Automata. Finite Automata (FA) FA also called Finite State Machine (FSM) –Abstract model of a computing entity. –Decides.
Languages Given an alphabet , we can make a word or string by concatenating the letters of . Concatenation of “x” and “y” is “xy” Typical example: 
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 3 Mälardalen University 2010.
Fundamentals of Informatics
Recognising Languages We will tackle the problem of defining languages by considering how we could recognise them. Problem: Is there a method of recognising.
CSCI 3130: Formal languages and automata theory Tutorial 1 Lee Chin Ho.
Lecture Notes 
1 Course Overview Why this course “formal languages and automata theory?” What do computers really do? What are the practical benefits/application of formal.
Finite Automata Great Theoretical Ideas In Computer Science Victor Adamchik Danny Sleator CS Spring 2010 Lecture 20Mar 30, 2010Carnegie Mellon.
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen.
CS 404Ahmed Ezzat 1 CS 404 Introduction to Compiler Design Lecture 1 Ahmed Ezzat.
L ECTURE 3 T HEORY OF AUTOMATA. E QUIVALENT R EGULAR E XPRESSIONS Definition Two regular expressions are said to be equivalent if they generate the same.
Lecture #4 Thinking of designing an abstract machine acts as finite automata. Advanced Computation Theory.
Theory of Computation Automata Theory Dr. Ayman Srour.
Lecture Three: Finite Automata Finite Automata, Lecture 3, slide 1 Amjad Ali.
Introduction to Automata Theory Theory of Computation Lecture 3 Tasneem Ghnaimat.
Finite Automata.
Languages.
Lexical analysis Finite Automata
Lecture2 Regular Language
CSE 105 theory of computation
Deterministic Finite Automata
Chapter 2 FINITE AUTOMATA.
Deterministic Finite Automata
Finite State Machines.
THEORY OF COMPUTATION Lecture One: Automata Theory Automata Theory.
Chapter Two: Finite Automata
CSE322 Definition and description of finite Automata
Intro to Data Structures
4b Lexical analysis Finite Automata
4b Lexical analysis Finite Automata
CSCI 2670 Introduction to Theory of Computing
AUTOMATA THEORY.
CSE 105 theory of computation
Presentation transcript:

COMS 3261, Lecture 2 Strings, Languages, Automata September 6, 2001

Agenda Today Strings Languages Deterministic Finite Automata For next time: Read up to 1.2 Check out ABCEZ in lecture 2-4 directory. Due 9/13: HW 1

Vending Machine Example Vending machine dispenses soda for $0.45 Accepts only dimes and quarters Eats your money if you don’t have correct change Model this by Java-method pseudocode:

Vending Machine Example Soda vend(){ int total = 0, coin; while (total != 45){ receive(coin); if ((coin==10 && total==40) ||(coin==25 && total>=25)) reject(coin); else total += coin; } return new Soda(); }

Vending Machine Example Why was this over-kill?

Vending Machine Example Why was this over-kill? 1) Vending machines have been around long before computers or Java! 2) Don’t really need int ’s. Each int introduces 2 32 possibilities multiplicatively!!! 3) Don’t need to know how to add integers to model venting machine ( total += coin ) 4) if/else, Java grammar, all really artifices that just complicate the essence

Vending Machine Example

Input: DQQD About to put in a dime

Vending Machine Example Input: DQQD About to put in a quarter

Vending Machine Example Input: DQQD About to put in a quarter

Vending Machine Example Input: DQQD About to put in a dime

Vending Machine Example Input: DQQD DONE! MONEY ACCEPTED.

Vending Machine Example What made this example simpler than the Java pseudocode?

Vending Machine Example 1. Only needed two coin types “D” and “Q” – symbols/letters in alphabet 2. Only needed 7 possible current total amounts – states/nodes/vertices 3. Much cleaner and aesthetically pleasing than Java lingo Now generalize and abstractify…

Alphabets, Strings, Languages DEF: An alphabet   is a set of symbols (characters, letters). A string (or word) over   is a sequence of symbols. The empty string is the string containing no symbols at all, and is denoted by  Q1: What is   in our vending machine example? Q2: What are some good/bad strings in our example? Q3: What does  signify in our example?

Alphabets, Strings, Languages A1:   D, Q  A2: Good: QDD, DQD, DDQ, QQQQDD, etc. Bad: Q, D, DD, etc. Ugly: DDD …now you’re screwed! A3:  signifies trying to get something for nothing (putting no money in at all).

Alphabets, Strings, Languages DEF: The length of a string is the number of symbols that it contains (repetitions allowed). Absolute values are used to denote length. EG: Lengths of the above good (QDD, DQD, DDQ, QQQQDD) are: 3, 3, 3, 6 Q: What’s the length of  ?

Alphabets, Strings, Languages A: 

Alphabets, Strings, Languages DEF: The concatenation of two strings is the string resulting from putting them together from left to right. Given strings u and v, denote the concatenation by u  v, or just uv. EG: ire   land = ireland, QQ   DD = QQDD, DDD   u is still bad, no-matter what u is! Q1: Why the last claim? Q2: What’s the Java equivalent of concatenation? Q3: Find a formula for  u  v 

Alphabets, Strings, Languages A1: You are still screwed no matter what combination of coins you put in. A2: The + operator on strings. A3:  u  v  u  +  v 

Alphabets, Strings, Languages DEF: The reversal of a string u is denoted by u R. EG: (banana) R = ananab DEF: If  is an alphabet,   denotes the set of all strings over  A language over  is a subset of  , i.e. a set of strings each consisting of sequences of letters in 

Alphabets, Strings, Languages EG:   D, Q    , D, Q, DD, DQ, QD, QQ, DDD, DDQ, DQD, DQQ, QDD, QDQ, QQD, QQQ, DDDD, DDDQ, …  Define L =  u   | u successfully vends  Classroom exercise: What are all the strings in L of length 1? Of length 2? 3? 4? 5?

Finite Deterministic Automata More computer-like example: 0 1 sourceless arrow denotes start double circle denotes accept input put on tape read left to right

Finite Deterministic Automata

REJECT!

Finite Deterministic Automata Q: What kinds of bitstrings are accepted?

Finite Deterministic Automata A: Bitstrings that represent binary even numbers.

Finite Deterministic Automata Exercise: Design with a friend a machine that tells us when a base-10 number is divisible by 3. What should your alphabet be? How can you tell when a number is divisible by 3?

Finite Deterministic Automata Solution: (except for  0 mod 3 1 mod 3 2 mod 3 0,3,6,9 1,4,7 2,5,8

Formal Definition of FA DEF: A (deterministic ) finite automaton (FA) consists of a set of states Q, an alphabet , labeled transitions between states , a start state q 0  Q, and a set of accept states F. This is all encapsulated by the “5-tuple” M = (Q, , , q 0, F )

Formal Definition of FA Notice that the input string, as well as the tape containing the input string, are implicit in the definition of an FA. I.e., definition only deals with static view. Further explaining needed for understanding how FA’s interact with their input.

Why Deterministic? Deterministic means that there is enough information to always determine which state the Automaton goes into next, when reading a particular symbol. Our Vending Machine Example was actually not deterministic because after $.45 have been deposited, the effects of an additional coin deposit are undefined. Vending Machine Example

0 mod 3 1 mod 3 2 mod 3 0,3,6,9 1,4,7 2,5,8 Exercise: Find the formal description of this automaton.

Definition of FA, example Q = { 0 mod 3, 1 mod 3, 2 mod 3 } ( rename: {q 0, q 1, q 2 } )  = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 } q 0 = 0 mod 3 F = { 0 mod 3 }  -- further explanation required

The labeling function   tells us which state to go to, if machine reads a given symbol. I.e., given a source state in Q and a letter in ,  defines a unique target state in Q. In other words,  is a function from the Cartesian product Q x  to Q :

The labeling function 

Usually don’t have such neat and Simple formulas.

Formal Definition of an FA: Dynamic How does an FA operate on strings? Implicitly, there is some notion of an auxiliary tape containing the string. The FA reads the tape from left to right with each new character causing the FA to go into another state. When the string is completely read, the string is accepted depending on whether the FA’s final state was an accept state.

Formal Definition of an FA: Dynamic DEF: A string u is accepted by an automaton iff (IF and only iF ) the path starting at q 0 which is labeled by u ends in an accept state. Note: To really define what it means for string to label a path, you need to break u up into its sequence of characters and apply  repeatedly, keeping track of states. See Sipser for further details.

Language Accepted by an FA DEF: The language accepted by an FA M is the set of all strings which are accepted by M and is denoted by L (M ). Intuitively, think of all the possible ways of getting from the start state to any accept state. Then think of all the possible ways of labeling those paths (if there are multiple labels on some edges).

Regular Languages We will eventually see that not all languages can be described as the accepted language of some FA. Languages which do belong to some FA, exhibit a high degree of regularity and fit the pattern defined by the FA. In fact, DEF: A language L is called a regular language if some FA M exists such that L = L (M ).

Blackboard exercises