Finite Automata Alphabet word

Slides:



Advertisements
Similar presentations
Nondeterministic Finite Automata CS 130: Theory of Computation HMU textbook, Chapter 2 (Sec 2.3 & 2.5)
Advertisements

YES-NO machines Finite State Automata as language recognizers.
Finite Automata Course: Theory of Computation Date: Nov 16 th, 2011 Lin Liu lliu AT cs.kent.edu.
1 Languages. 2 A language is a set of strings String: A sequence of letters Examples: “cat”, “dog”, “house”, … Defined over an alphabet: Languages.
Finite Automata Section 1.1 CSC 4170 Theory of Computation.
Intro to DFAs Readings: Sipser 1.1 (pages 31-44) With basic background from Sipser 0.
Intro to DFAs Readings: Sipser 1.1 (pages 31-44) With basic background from Sipser 0.
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 Finite Automata. 2 Finite Automaton Input “Accept” or “Reject” String Finite Automaton Output.
1 Languages and Finite Automata or how to talk to machines...
Fall 2005 CSE 467/567 1 Formal languages regular expressions regular languages finite state machines.
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 Non-Deterministic Finite Automata. 2 Alphabet = Nondeterministic Finite Automaton (NFA)
CS 3240: Languages and Computation Pushdown Automata & CF Grammars NOTE: THESE ARE ONLY PARTIAL SLIDES RELATED TO WEEKS 9 AND 10. PLEASE REFER TO THE TEXTBOOK.
Regular Languages A language is regular over  if it can be built from ;, {  }, and { a } for every a 2 , using operators union ( [ ), concatenation.
Lecture 23: Finite State Machines with no Outputs Acceptors & Recognizers.
Theory of Computation - Lecture 3 Regular Languages What is a computer? Complicated, we need idealized computer for managing mathematical theories... Hence:
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: 
CMSC 330: Organization of Programming Languages Finite Automata NFAs  DFAs.
Finite Automata – Definition and Examples Lecture 6 Section 1.1 Mon, Sep 3, 2007.
Lecture # 12. Nondeterministic Finite Automaton (NFA) Definition: An NFA is a TG with a unique start state and a property of having single letter as label.
Lecture 4 Theory of AUTOMATA
Lecture Notes 
Pushdown Automata Hopcroft, Motawi, Ullman, Chap 6.
1 Chapter 2 Finite Automata (part a) Hokkaido, Japan.
  An alphabet is any finite set of symbols.  Examples: ASCII, Unicode, {0,1} ( binary alphabet ), {a,b,c}. Alphabets.
Costas Busch - LSU1 Deterministic Finite Automata And Regular Languages.
Theory of Computation Automata Theory Dr. Ayman Srour.
Recap: Nondeterministic Finite Automaton (NFA) A deterministic finite automaton (NFA) is a 5-tuple (Q, , ,s,F) where: Q is a finite set of elements called.
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, grammars, automata
Finite Automata Alphabet word
Languages.
Chapter 2 Scanning – Part 1 June 10, 2018 Prof. Abdelaziz Khamis.
Lexical analysis Finite Automata
Lecture2 Regular Language
CSC312 Automata Theory Chapter # 5 by Cohen Finite Automata
Theory of Computation Lecture # 9-10.
Pushdown Automata PDAs
Pushdown Automata PDAs
AUTOMATA THEORY VI.
Deterministic Finite Automata
Nondeterministic Finite Automata
Finite Automata & Regular Languages
Jaya Krishna, M.Tech, Assistant Professor
Deterministic Finite Automata
CSE322 Finite Automata Lecture #2.
Non-Determinism 12CS45 Finite Automata.
THEORY OF COMPUTATION Lecture One: Automata Theory Automata Theory.
Deterministic Finite Automata And Regular Languages Prof. Busch - LSU.
CSE322 Definition and description of finite Automata
Principles of Computing – UFCFA3-30-1
Finite Automata.
4b Lexical analysis Finite Automata
Chapter Five: Nondeterministic Finite Automata
4b Lexical analysis Finite Automata
CSC312 Automata Theory Chapter # 5 by Cohen Finite Automata
Principles of Computing – UFCFA3-30-1
RECAP Lecture 7 FA of EVEN EVEN, FA corresponding to finite languages(using both methods), Transition graphs.
CSC 4170 Theory of Computation Finite Automata Section 1.1.
Chapter # 5 by Cohen (Cont…)
Recap Lecture 4 Regular expression of EVEN-EVEN language, Difference between a* + b* and (a+b)*, Equivalent regular expressions; sum, product and closure.
LECTURE # 07.
Non Deterministic Automata
What is it? The term "Automata" is derived from the Greek word "αὐτόματα" which means "self-acting". An automaton (Automata in plural) is an abstract self-propelled.
Presentation transcript:

Finite Automata Alphabet word Alphabet and words 1 Alphabet … finite (unempty) set of symbols |A| … size of alphabet A Alphabet Examples: A = { ‘A’, ‘D’, ‘G’, ‘O’, ‘U’}, |A| = 5 A = {0,1}, |A| = 2 A = { , , }, |A| = 3 Word (over alphabet A) … finite (maybe empty) sequence also string of symbols of alhabet (A) |w| … length of word w word Examples: w = OUAGADOUGOU, |w| = 11 w = 1001, |w| = 4 w = , |w| = 5

Finite Automata 2 Language 1 Language … set of words (=strings) (not necessarily finite, can be empty) |L| … cardinality of language L Language 1 Language specification -- List of all words of the language (only for finite language!) Examples: A1 = {‘A’, ‘D’, ‘G’, ‘O’, ‘U’} L1 = {ADA, DOG, GOUDA, D, GAG}, |L1| = 5 A2 = {0,1} L2 = {0, 1, 00, 01, 10, 11}, |L2| = 6 A3 = { , , } L3 = { , , }, |L2| = 3

Finite Automata 2 Language specification -- Informal (but unambiguous) 3 2 Language specification -- Informal (but unambiguous) description in natural human language (usually for infinite language) Examples: A1 = {‘A’, ‘D’, ‘G’, ‘O’, ‘U’} L1: Set of all words over A1, which begin with DA, end with G a and do not contain subsequence AA. L1 = {DAG, DADG, DAGG, DAOG, DAUG, DADAG, DADDG… } |L1| =  A2 = {0,1} L2: Set of all words over A2, which contain more 1s than 0s and each 0 is followed by at least two 1s. L2 = { 1, 11, 011, 0111, 1011, 1111, … , 011011, 011111, … } |L2| = 

Finite Automata 3 Language specification -- By finite automaton 4 3 Language specification -- By finite automaton Finite automaton is a five-tuple (A, Q, σ, S0, QF), where: A Q σ S0 QF … alphabet … finite set of symbols |A| ... size of alphabet ... set of states (often numbered) (what is „a state“ ?) ... transition function ... σ: QA Q ... start state S0  Q ... unempty set of final states  ≠ QF  Q

Finite Automata Automaton FA1: A Q σ S0 QF … alphabet … {0,1}, |A| = 2 5 Automaton FA1: A Q σ S0 QF … alphabet … {0,1}, |A| = 2 ... set of states {S, A, B, C, D } ... transition function ... σ: QA  Q : { σ(S,0) = S, σ(A,0) = B, σ(B,0) = C, σ(C,0) = C, σ(D,0) = D, σ(S,1) = A, σ(A,1) = D, σ(B,1) = D, σ(C,1) = A, σ(D,1) = D } ... start state S  Q … unempty set of final states  ≠ { C }  Q C S A B 1 D 0,1 Transition diagram of the automaton FA1 FA1

Finite Automata FA1 1 1 1 S A B C 1 1 D 0,1 FA1 1 1 1 S A B C 1 1 D Example 6 FA1 1 1 1 S A B C 1 1 D 0,1 FA1 1 1 1 S A B C 1 1 D 0,1

Finite Automata FA1 1 1 1 S A B C 1 1 D 0,1 FA1 1 1 1 S A B C 1 1 D Example 7 FA1 1 1 1 S A B C 1 1 D 0,1 FA1 1 1 1 S A B C 1 1 D 0,1

Finite Automata FA1 1 1 1 S A B C 1 1 D 0,1 FA1 1 1 1 S A B C 1 1 D Example 8 FA1 1 1 1 S A B C 1 1 D 0,1 FA1 1 1 1 S A B C 1 1 D 0,1

 Finite Automata FA1 1 1 1 S A B C 1 1 D 0,1 Example 9 FA1 1 1 1 S A B C 1 1 D 0,1 When the last word symbol is read automaton FA1 is in final state  Word 1 is accepted by automaton FA1

Finite Automata FA1 1 1 1 S A B C 1 1 D 0,1 FA1 1 1 1 S A B C 1 1 D Example 10 FA1 1 1 1 S A B C 1 1 D 0,1 FA1 1 1 1 S A B C 1 1 D 0,1

Finite Automata FA1 1 1 1 1 S A B C 1 1 D 0,1 FA1 1 1 1 1 S A B C 1 1 Example 11 FA1 1 1 1 1 S A B C 1 1 D 0,1 FA1 1 1 1 1 S A B C 1 1 D 0,1

Finite Automata FA1 1 1 1 1 S A B C 1 1 D 0,1 FA1 1 1 1 1 S A B C 1 1 Example 12 FA1 1 1 1 1 S A B C 1 1 D 0,1 FA1 1 1 1 1 S A B C 1 1 D 0,1 FA1

is not accepted by automaton FA1 Finite Automata Example 13 FA1 1 1 1 1 S A B C 1 1 D 0,1 When the last word symbol is read automaton FA1 is in a state which is not final  Word 1 1 is not accepted by automaton FA1

Finite Automata FA1 1 1 1 1 1 ... S A B C 1 1 D 0,1 FA1 1 1 1 1 1 ... Example 14 FA1 1 1 1 1 1 ... S A B C 1 1 D 0,1 FA1 1 1 1 1 1 ... S A B C 1 1 D 0,1

Finite Automata FA1 1 1 1 1 1 ... S A B C 1 1 D 0,1 FA1 1 1 S A B C 1 Example 15 FA1 1 1 1 1 1 ... S A B C 1 1 D 0,1 FA1 1 1 S A B C 1 1 1 ... 1 1 D ,1

Finite Automata FA1 1 1 1 1 1 ... S A B C 1 1 D 0, 1 Example 16 FA1 1 1 1 1 1 ... S A B C 1 1 D 0, 1 No word starting with 1 1 ... is accepted by automaton FA1 No word containing ... 1 1 ... is accepted by automaton FA1 No word containing ... 1 1 ... is accepted by automaton FA1 Automaton FA1 accepts only words -- containing at least one 1 -- containing at least two 0s after each 1 Language accepted by automaton = set of all words accepted by automaton

Finite Automata Automaton activity: Word recognition 17 Automaton activity: At the begining the automaton is in the start state. Next it reads the input word symbol by symbol and transits to other states according to the transition function. When the word is read the automaton is again in some state. If it is in a final state, we say that it accepts the word, if it is not in a final state, we say that it does not accept the word. All words accepted by the automaton represent a language accepted (or recognized) by the automaton.

Finite Automata S A C 1 Language over alphabet {0,1} : Example 18 S A C B D 1 Language over alphabet {0,1} : If the word starts with 0, it ends with 1, If the word starts with 1, it ends with 0. Automat FA2 Example of analysis of different words by FA2: 0 1 0 1 0 : (S),0 → (A),1 → (B),0 → (A),1 → (B),0 → (A) (A) is not a final state, word 0 1 0 1 0 is rejected by FA2. 1 0 1 1 0 : (S),1 → (C),0 → (D),1 → (C),1 → (C),0 → (D) (D) is a final state, word 1 0 1 1 0 is accepted by FA2.

Finite Automata Language: { 0 1 0, 0 1 1 0, 0 1 1 1 0, 0 1 1 1 1 0, Example 19 Language: { 0 1 0, 0 1 1 0, 0 1 1 1 0, 0 1 1 1 1 0, 0 1 1 1 1 1 0, ... } 1 1 S A B C 1 0,1 D 0,1 Automaton FA3 Example of analysis of different words by FA3: 0 1 0 1 0 : (S),0 → (A),1 → (B),0 → (C),1 → (D),0 → (D) (D) is not a final state, word 0 1 0 1 0 is rejected by FA3. 0 1 1 1 0 : (S),0 → (A),1 → (B),1 → (B),1 → (B),0 → (C) (C) is a final state, word 0 1 1 1 0 is accepted by FA3.

Finite Automata 1 1 0,1 1 Automat FA4 S A B C Example 20 1 1 0,1 1 Automat FA4 S A B C Automaton FA4 accepts each word over the alphabet {0,1} which contains subsequence ... 1 ... Example of analysis of different words by FA4: 0 0 1 0 1 : (S),0 → (A),0 → (A),1 → (B),0 → (C),1 → (C) (C) is a final state, word 0 0 1 0 1 is accepted by FA4. 0 1 1 1 0 : (S),0 → (A),1 → (B),1 → (S),1 → (S),0 → (A) (A) is not a final state, word 0 1 1 1 0 is rejected by FA4.

Finite Automata Example 21 Language over the alphabet { +, - , . , 0, 1, …, 8, 9, … } whose words represent a decimal numbers 0,1,...,9 0,1,...,9 0,1,...,9 . 0,1,...,9 +,- 0,1,...,9 1 2 3 4 else else else else else 5 Automaton FA5 any symbol Example of word analysis +87.09: (0),+ → (1),8 → (2),7 → (2), . → (3),0 → (4),9 → (4) (4) is a final state, word +87.05 is accepted by FA5. 76+2: (0),7 → (2),6 → (2),+ → (5),2 → (5) (5) is not a final state, word 76+2 is not accepted by FA5.

Code of the finite automaton Finite Automata Implementation 22 4 3 5 1 +,- . 2 0,1,...,9 else any symbol Code of the finite automaton (The word which is being read is stored in the array arr[ ]): int isDecimal(char arr[], int length) { int i; int state = 0; for(i = 0; i < length; i++) { // check each symbol switch (state) { ...

. Finite Automata 4 3 5 1 +,- 2 case 0: Implementation 23 4 3 5 1 +,- . 2 0,1,...,9 else any symbol case 0: if ((arr[i] == '+') || (arr[i] == '-')) state = 1; else if ((arr[i] >= '0') && (arr[i] <= '9')) state = 2; else state = 5; break;

. Finite Automata 4 3 5 1 +,- 2 case 1: Implementation 24 4 3 5 1 +,- . 2 0,1,...,9 else any symbol case 1: if ((arr[i] >= '0') && (arr[i] <= '9')) state = 2; else state = 5; break;

. Finite Automata 4 3 5 1 +,- 2 case 2: Implementation 25 4 3 5 1 +,- . 2 0,1,...,9 else any symbol case 2: if ((arr[i] >= '0') && (arr[i] <= '9')) state = 2; else if (arr[i] == '.') state = 3; else state = 5; break;

. Finite Automata 4 3 5 1 +,- 2 case 3: Implementation 26 4 3 5 1 +,- . 2 0,1,...,9 else any symbol case 3: if ((arr[i] >= '0') && (arr[i] <= '9')) state = 4; else state = 5; break; case 4: case 5: break; // no need to react anyhow default : break; } // end of switch 3 4 5

Finite Automata Implementation 27 4 3 5 1 +,- . 2 0,1,...,9 else any symbol } // end of for loop -- word has been read if ((state == 2) || (state == 4)) // final states!! return 1; // success - decimal OK else return 0; // not a decimal } // end of function isDecimal() 2 4