Presentation is loading. Please wait.

Presentation is loading. Please wait.

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: 

Similar presentations


Presentation on theme: "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: "— Presentation transcript:

1 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:  ={0,1}, the possible words over  are the finite bit strings. A language is a set of words.

2 More about Languages The empty string  is the unique string with zero length. Concatenation of two langauges: A B = { xy | x  A and y  B } Typical examples: L = { x | x is a bit string with two zeros } L = { a n b n | n  N } L = {1 n | n is prime}

3 A Word of Warning Do not confuse the concatenation of languages with the Cartesian product of sets. For example, let A = {0,00} then AA = { 00, 000, 0000 } with |AA|=3, A  A = { (0,0), (0,00), (00,0), (00,00) } with |A  A|=4

4 Recognizing Languages Let L be a language  S a machine M recognizes L if M xSxS “accept” “reject” if and only if x  L if and only if x  L

5 Finite Automaton The most simple machine that is not just a finite list of words. “Read once”, “no write” procedure. It has limited memory to hold the “state”. Examples: vending machine, cell-phone, elevator, etc.

6 A Simple Automaton (0) q1q1 q2q2 q3q3 10 0,1 01 statestransition rules starting state accepting state

7 A Simple Automaton (1) q1q1 q2q2 q3q3 10 0,1 01 on input “0110”, the machine goes: q 1  q 1  q 2  q 2  q 3 = “reject” start accept

8 A Simple Automaton (2) q 1  q 2  q 3  q 2 = “accept” q1q1 q2q2 q3q3 10 0,1 01 on input “101”, the machine goes:

9 A Simple Automaton (3) 010: reject 11: accept 010100100100100: accept 010000010010: reject  : reject q1q1 q2q2 q3q3 10 01 0,1 The set of strings accepted by a DFA M is denoted by L(M), the language of the machine M. We want to build DFA for various languages and also want to understand the ones for which we can’t build a DFA.

10 Finite Automaton (definition) A deterministic finite automaton (DFA) M is defined by a 5-tuple M=(Q, , ,q 0,F) –Q: finite set of states –  : finite alphabet –  : transition function  :Q  Q –q 0  Q: start state –F  Q: set of accepting states

11 M = states Q = {q 1,q 2,q 3 } alphabet  = {0,1} start state q 1 accept states F={q 2 } transition function  : q1q1 q2q2 q3q3 1 0 0 1 0,1 0 1 q1q1 q 1 q2q2 q2q2 q3q3 q2q2 q3q3 q2q2 q2q2

12 Recognizing Languages (definition) A finite automaton M = (Q, , ,q,F) accepts a string/word w = w 1 …w n if and only if there is a sequence r 0 …r n of states in Q such that: 1) r 0 = q 0 2)  (r i,w i+1 ) = r i+1 for all i = 0,…,n–1 3) r n  F

13 Regular Languages The language recognized by a finite automaton M is denoted by L(M). A regular language is a language for which there exists a recognizing finite automaton.

14 Examples of regular languages L 1 = { x | x has an odd number of 1’s } over alphabet {0, 1} L 2 = { x | x has at least one 0 and at least one 1} over alphabet {0, 1} L 3 = { x | x represents a positive integer that is divisible by 3} We will show that each of these languages is regular by building a DFA.


Download ppt "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: "

Similar presentations


Ads by Google