• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Theory of Computation: Deterministic Finite Automata (DFA), Finite Automaton for Robotic Camera & Arm, DFA Transition Functions, Regular Languages, DFA Problems, DFAs in Java
 

Theory of Computation: Deterministic Finite Automata (DFA), Finite Automaton for Robotic Camera & Arm, DFA Transition Functions, Regular Languages, DFA Problems, DFAs in Java

on

  • 1,253 views

 

Statistics

Views

Total Views
1,253
Views on SlideShare
1,066
Embed Views
187

Actions

Likes
0
Downloads
16
Comments
0

19 Embeds 187

http://vkedco.blogspot.com 124
http://www.vkedco.blogspot.com 18
http://vkedco.blogspot.in 11
http://vkedco.blogspot.co.uk 5
http://reader.aol.com 4
http://vkedco.blogspot.co.il 4
http://www.vkedco.blogspot.in 4
http://vkedco.blogspot.com.es 3
http://vkedco.blogspot.de 3
http://vkedco.blogspot.com.ar 2
http://vkedco.blogspot.ru 1
http://www.vkedco.blogspot.nl 1
http://vkedco.blogspot.mx 1
http://www.vkedco.blogspot.jp 1
http://www.vkedco.blogspot.fr 1
http://www.vkedco.blogspot.de 1
http://www.vkedco.blogspot.co.nz 1
http://www.blogger.com 1
http://vkedco.blogspot.sk 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Theory of Computation: Deterministic Finite Automata (DFA), Finite Automaton for Robotic Camera & Arm, DFA Transition Functions, Regular Languages, DFA Problems, DFAs in Java Theory of Computation: Deterministic Finite Automata (DFA), Finite Automaton for Robotic Camera & Arm, DFA Transition Functions, Regular Languages, DFA Problems, DFAs in Java Presentation Transcript

    • Theory of Computation Deterministic Finite Automata Vladimir Kulyukin www.vkedco.blogspot.com
    • Outline ● Blocks World Problem: A DFA for a Robotic Camera & Arm ● How DFAs Work ● DFA Transition Function ● Formal Languages Accepted by DFAs ● Sample DFA Problems ● Sample DFA Implementation www.vkedco.blogspot.com
    • Outline ● Deterministic Finite Automata (DFA) ● How DFAs Work ● DFA Transition Function ● Formal Languages Accepted by DFAs ● Sample DFA Problems ● Sample DFA Implementation www.vkedco.blogspot.com
    • Blocks World Problem www.vkedco.blogspot.com
    • A B Suppose we want to design a control system for a robotic camera & arm unit that should build two-block towers: a on b or b on a. Blocks World Problem www.vkedco.blogspot.com
    • A B Goal State 01: A on B www.vkedco.blogspot.com
    • B A Goal State 02: B on A www.vkedco.blogspot.com
    • Robotic Arm & Camera Operations • puton(X, Y) – put A on top of Y • clear(X) – verify that X's top is clear • on(X, Y) – verify that X is on top of Y www.vkedco.blogspot.com
    • Finite Automaton for Blocks World Problem on(A, T) on(B, T) clear(A) clear(B) on(A, B) on(B, T) clear(A) on(B, A) on(A, T) clear(B) puton(A, B) puton(A, T) puton(B, A) puton(B, T) www.vkedco.blogspot.com
    • Back to Automata & Languages www.vkedco.blogspot.com
    • Deterministic Finite Automata • A DFA can be informally defined as a directed graph whose nodes are states and whose edges are transitions on specific symbols • A DFA has a unique start state and a set (possibly empty) of final or accepting states • A DFA processes the input string one symbol at a time. When the last symbol is read, the DFA reaches a state which is either final or not. If the state is final, the DFA accepts (recognizes) the string. If the state is not final, the DFA rejects the string www.vkedco.blogspot.com
    • DFA: Formal Definition ( ) states.(final)acceptingofsettheis state;starttheis ;:function;ntransitioais alphabet;anis states;ofsetfiniteais :where ,,,,,i.e.tuple,-5aisDFAA 0 0 F Qq QQ Q FqQMM ∈ →Σ× Σ Σ= δδ δ www.vkedco.blogspot.com
    • Example 1: DFA M q1q0 a b b a q0 is the start state. q1 is the final state. www.vkedco.blogspot.com
    • Example 1: DFA M ( ) { } { } { } ( ) ( ) ( ) ( ) 01 100010 1 10 0 , ;,;,;,.4 ;.3 ;,.2 ;,1. where,,,,, qbq qaqqbqqaq qF ba qqQ FqQM = === = =Σ = Σ= δ δδδ δ www.vkedco.blogspot.com
    • How DFAs Work www.vkedco.blogspot.com
    • Example: DFA M a b q0 q1 q0 q1 q1 q0 The transition function, δ, can be represented as a table: www.vkedco.blogspot.com
    • How DFA M Works q0 b a a b a www.vkedco.blogspot.com
    • How DFA M Works q0 b a a b a www.vkedco.blogspot.com
    • How DFA M Works q1 b a a b a www.vkedco.blogspot.com
    • How DFA M Works q1 b a a b a
    • How DFA M Works q0 b a a b a www.vkedco.blogspot.com
    • How DFA M Works q1 b a a b a www.vkedco.blogspot.com
    • How DFA M Works q1 b a a b a ecognizedaccepted/risThus, baaba www.vkedco.blogspot.com
    • Observations on DFA Definition ● Q may not be empty: a DFA must have at least one state, i.e., the start state ● δ is a function, i.e., it must be for every state in Q and every symbol in Σ ● F may be empty, in which case the DFA accepts the empty language ● F can be equal to Q, in which case the DFA accepts Σ* www.vkedco.blogspot.com
    • δ* :DFA Transition Function www.vkedco.blogspot.com
    • The δ* Function ( ) ( ) ( )( )axqxaq qq ,,,.2 ;,.1 :statestostringsmaps ** * * δδδ εδ δ = = www.vkedco.blogspot.com
    • Back to Example DFA M ( ) ( )( ) ( )( )( ) ( )( )( )( ) ( )( )( ) ( )( ) ( ) Fqaqabq abbqabbq abbqabbqbbaq bba ∈== == === 100 00 * 0 * 0 * 0 * ,,, ,,,,,,, ,,,,,, accepted?itIs.isinputtheSuppose δδδ δδδεδδδδ δδδδδδ www.vkedco.blogspot.com
    • Languages Accepted by DFAs www.vkedco.blogspot.com
    • DFA String Acceptance ( ) ( ) FxqFqQM x ∈Σ= Σ∈ ,ifonlyandif,,,, DFAabyecognizedaccepted/risstringA 0 * 0 * δδ www.vkedco.blogspot.com
    • DFA’s Language: L(M) ( ) ( ) ( ){ }.,|Then .,,,,such thatDFAabeLet 0 ** 0 FxqxML FqQMM ∈Σ∈= Σ= δ δ www.vkedco.blogspot.com
    • Regular Languages A language L is regular if and only if there exits a DFA M such that L(M) = L. www.vkedco.blogspot.com
    • Sample DFA Problems www.vkedco.blogspot.com
    • Typical DFA Problems ● Given a DFA M and a set of strings, determine which strings are in the language of M, i.e. L(M)? ● Given a DFA M, state in the set former notation, state L(M)? ● Draw a DFA diagram given the formal definition of the DFA www.vkedco.blogspot.com
    • Problem 01 q0 q1 a a b Which of the following strings are in L(M)? 1. b 2. ε 3. ab 4. abba 5. ababaaaaba b www.vkedco.blogspot.com
    • Solution 01 ( ) ( ) ( ) ( )( ) ( ) ( ) ( ) ( )( ) ( )( )( ) ( )( )( )( ) ( )( )( ) ( )( ) ( ) ( ) Fqababaaaabaq Fqaqabqabbq abbaq ababq aabbqabbaq MLab Fqbqbaqabq ML MLb ∈= ∉=== = = == ∈ ∈=== ∉ ∉ 10 * 0111 0 * 0 * 0 * 0 * 110 * 0 * ,.5 ,,,,,, ,,,, ,,, ,,,.4 So,.,,,,.3 .2 .1 δ δδδδδδ δδδδ δδδ δδδ δδδδ ε www.vkedco.blogspot.com
    • Problem 02 q0 q1 a,b a,b What is the language accepted by this DFA M? www.vkedco.blogspot.com
    • Solution 02 { } ( ) { }{ }.,12and,| :answerFormal odd.islengthwhose,overstringsAll :answerInformal * NnnxbaxxML ba ∈+=∈= www.vkedco.blogspot.com
    • Problem 03 q0 q1 b a a b What is the language accepted by this DFA M? www.vkedco.blogspot.com
    • Solution 03 { } ( ) { }{ }* ,and| :answerFormal inendthat,overstringsAll :answerInformal bayyaxxML aba ∈== www.vkedco.blogspot.com
    • Problem 04 { }{ } { }{ }oddisins'ofnumber|,.2 ,|1. :itacceptsthat DFAadrawlanguages,followingtheofeachFor * * xabax baxx ∈ ∈ www.vkedco.blogspot.com
    • Solution 04.1 q0 a,b www.vkedco.blogspot.com
    • Solution 04.2 q0 q1 b b a a www.vkedco.blogspot.com
    • Problem 05 { } { } { }( ) ( ) ( ) ( ) ( ) 01 01 10 10 1010 , ;, ;, ;, ,,,,,,, :DFAthisDraw qbq qaq qbq qaq qqbaqq = = = = δ δ δ δ δ www.vkedco.blogspot.com
    • Solution 05 q0 q1 a,b a,b www.vkedco.blogspot.com
    • Sample DFA Implementation www.vkedco.blogspot.com
    • A DFA: Odd Numbers of Zeros q0 q1 0 0 www.vkedco.blogspot.com
    • Java Implementation: Part 1 import java.io.*; public class OddNumZeros {    private static final int q0 = 0;    private static final int q1 = 1;    private static final int q2 = 2; // this is the sink    private int state; // current state … } www.vkedco.blogspot.com
    • Java Implementation: Part 2 static private int delta(int s, char c) {        switch (s) {            case q0: switch (c) {                case '0': return q1;                default: return q2; // go to the sink            }            case q1: switch (c) {                case '0': return q0;                default: return q2; // go to the sink            }            default: return q2; // go to the sink        } } www.vkedco.blogspot.com
    • Java Implementation: Part 3 public void deltaStar(String instr) {        char c;        for(int i = 0; i < instr.length(); i++) {            c = instr.charAt(i);            state = delta(state, c);        }    }    public boolean isInputAccepted() {        return state == q1;    } www.vkedco.blogspot.com
    • Java Implementation: Part 4 public void reset() { state = q0; } public static void main(String[] args) throws IOException {        OddNumZeros dfa = new OddNumZeros();        BufferedReader in =                new BufferedReader(new InputStreamReader(System.in));        String instr = in.readLine();        while ( instr != null )        {            dfa.reset();            dfa.deltaStar(instr);            if ( dfa.isInputAccepted() ) {                System.out.println(instr + " accepted");            }            else {                System.out.println(instr + " rejected");            }            instr = in.readLine();        } } www.vkedco.blogspot.com
    • References & Reading Suggestions ● A. Brooks Weber. Ch. 2 Formal Language: A Practical Introduction, Franklin, Beedle & Associates, Inc ● Davis, Weyuker, Sigal. Ch. 9. Computability, Complexity, and Languages, 2nd Edition, Academic Press www.vkedco.blogspot.com