MELJUN CORTES AUTOMATA Formal Language Lecture

download MELJUN CORTES AUTOMATA Formal Language Lecture

of 33

Transcript of MELJUN CORTES AUTOMATA Formal Language Lecture

  • 8/13/2019 MELJUN CORTES AUTOMATA Formal Language Lecture

    1/33

    Theory of Automata and

    Formal Language

    2002

    AUTOMATA THEORY PAGE 1

    SETSet

    It is any well defined collection of objects.

    It is a collection of distinct objects, without repetition and without ordering. It is denoted by capital letter.

    Example:A = {, ,0 ! = {", #, $% = {a, b, c, d & = {'en, (oseph

    Methods in Describing a Set:

    ". Listing Method) *oster + abular -orm

    'isting or enumerating all the elements of a gien set.Example: A = {a, b, c

    #. Rue Method) /et0%uilder -orm

    Elements hae properties in common. Elements must satisfy a gien rule or condition.

    Example: A = {x 1 x is a positie integer 2 3A = {x 1 x 2 4

    Ee!ent It is a member of a gien set or an object in the collection.

    It is denoted by small letter+s.Example:

    A = {a, b, c 5a A5 b A5 c A5 d A

    T"#es o$ Set

    ". %inite) elements can be counted.Example:

    A = {a, b, c

    #. &n$inite) elements cannot be counted.Example:

    A = {x 1 x is a positie integer

    Things to re!e!ber in isting ee!ents:

    ". 6rder of elements is not important#. *epetition must be ignored

    2003

  • 8/13/2019 MELJUN CORTES AUTOMATA Formal Language Lecture

    2/33

    Theory of Automata and

    Formal Language

    2002

    AUTOMATA THEORY'SetsPAGE (

    Subset ) * If A is a subset of %, A is contained in % or eery element of A is in %.

    Example:A = {a, b% = {a, b, cA + but + A

    ,ote:

    Eery set is a subset of itself.

    An empty set is a subset of eery set.

    If A % then there is at least one element in A that is not in %.

    Example: 'et A = {", #, $

    Subsets o$ A are:P )A*= {{", {#, {$, {", #, {", $, {#, $, {", #, $, {

    o chec7:1A1 = #n= 8

    Pro#er Subset ) or * A is a proper subset of % if A % and A %

    -ardinait" o$ the set ). .* It is the total number of elements in a gien setExample:

    A = {", #, $

    1A1 = $

    E!#t" Set / ,u or 0oid Set It is a set containing no elementExample : A = { or A = {

    A = { is not an empty set

    Singeton It is a set containing only one element.e.g. A = {"

    2003

  • 8/13/2019 MELJUN CORTES AUTOMATA Formal Language Lecture

    3/33

    Theory of Automata and

    Formal Language

    2002

    AUTOMATA THEORY'SetsPAGE

    -o!#arabe set At least one set is a subset of another set.

    !onditions so that A 9 % are comparable:1. A % 9 % A

    Example: A = {", #, $, 3% = {3, $, #, "

    2. A % 9 % AExample: A = {", #

    % = {", #, $

    3. A % 9 % AExample: A = {a, b, c

    % = {a, b

    ,on'-o!#arabe Set o set is a subset of the other set. ;A % 9 % A 9 A % " "" > >

    ransition -unction;>,x< = >

    ;>,y< = >

    ;",x< = "

    ;",y< = "

    T8o T"#es O$ %inite Auto!ata :

    ". Deter!inistic %inite Auto!ata)D%A*

    -or each input symbol in , there is exactly one transition of each state

    ;possibly bac7 to the state itself, , - = initial state= transition function- = set of final state

    2003

    AUTOMATA THEORY'%inite Auto!ata PAGE1

  • 8/13/2019 MELJUN CORTES AUTOMATA Formal Language Lecture

    10/33

    Theory of Automata and

    Formal Language

    2002

    Transition Diagra!Examples:". &iagrams that ends with ">.

    ransition able

    x y> " "" # "# $ "

    /trings that can be deried:

    "> >">

    >"">

    >">">

    ransition -unction;>,>< = >

    ;>,"< = "

    ;",>< = #

    ;","< = "

    ;#,>< = >

    ;#,"< = "

    #. &raw a transition diagram that will end with >>".

    2003

    AUTOMATA THEORY'%inite Auto!ata PAGE11

  • 8/13/2019 MELJUN CORTES AUTOMATA Formal Language Lecture

    11/33

    Theory of Automata and

    Formal Language

    2002

    (> ,on Deter!inistic %inite Auto!ata ),%A*

    *RE-ALL: In -A or &-A, for each input there is exactly one transition output of eachstate.

    'ets try to modify the finite automaton by alowing ?ero, one or moretransitions from a state on the same input symbol. he modified model iscalled on0&eterministic -inite Automaton.

    If for some of L, a, ;,a< does either to a uniue state or seeral statesor not states at all, then the -A is a -A.

    A on0&eterministic -inite Automaton is a uintuple K=;L,,>,,- = initial state - = set of final state

    It allows ?ero, one or more transitions for eery inputs symbol. Empty string accepted

    A seuence of symbols, say a", a#, ...an is accepted by -A if there exists aseuence of transition corresponding to the input seuence that leads fromthe initial states to the final state.

    Example:!onstruct a -A that accepts string ending with >"".

    ;>,>"">>not 3aid

    2003

    AUTOMATA THEORY',on Deter!inistic %inite Auto!ata),%A*PAGE 1(

  • 8/13/2019 MELJUN CORTES AUTOMATA Formal Language Lecture

    12/33

    Theory of Automata and

    Formal Language

    2002

    6he reason for the word OnondeterministicP is that we are in a state wherethere are multiple outgoing edges all haing the same input symbol ) we hae achoice of next state.

    6he only difference between a -A 9 &-A is that in &-A the next statefunction ta7es us to a uniuely defined state whereas in -A the next state ta7es us

    to a set of states.

    Example : ,%A Diagra!

    State Tabe

    > "

    > {>,$ {>,"

    " > {#

    # {# {#

    $ {3 >

    3 {3 {3

    Transition %unction

    'et the input be >">>" ;>, < = 2

    ;>, >< = ;;>, < = ;>,>,>< = ;;>,>",>< @

    ;",>,$@{ =F272

    ;#, >">>< = ;;>,>">,"< @ ;$,"< @ ;$,>,$ @

    {3=F272725

    ;#, >">>"< = ;;>,"< @ ;$,"< @ ;3,"< = {>," @ { @ {3 = F2721725

    2003

  • 8/13/2019 MELJUN CORTES AUTOMATA Formal Language Lecture

    13/33

    Theory of Automata and

    Formal Language

    2002

    AUTOMATA THEORY PAGE1

    EU&0ALE,-E o$ D%A and ,%A

    heorem: -or eery -A model, there exist one and only one euialent &-A

    'et K be the euialent &-A of a -A K.K=;L, ,,>,-,",#,{>,",{>,",{>,#,{",#,{>,",#% =#%9={#,{>,#,{",#,{>,",#

    Transition Tabe o$ ,%A

    > "

    > {> {>,"

    " {",#

    {

    # {# {Transition %unction ;{,>< = {

    ;{,"< = {

    ;>,>< = >

    ;>,"< = {>,"

    ;",>< = {",#

    ;","< = {

    ;#,>< = #

    ;#,"< = {

    ;;>,"< = {>,> @ (1,0)

    = > @ {",# = {>,",#

    ;;>,"," @ {} = {>,"

    ;;>,#< = {>,>< @ ;#,>< = {> @ {# = {>,#

    2003

  • 8/13/2019 MELJUN CORTES AUTOMATA Formal Language Lecture

    14/33

    Theory of Automata and

    Formal Language

    2002

    AUTOMATA THEORY' E2ui3aence o$ D%A and ,%APAGE 15

    ;;>,#,",# ;;",#< = {",>< @ ;#,>< = {",# @ {# = {",# ;;>,",#< = {>,>< @ ;",>< @ ;#,>< = {> @ {",# @ {# = {>,",# ;;>,",#,"

    State Tabe O$ D%A

    > "> {> {>,"

    " {",# {

    # {# {

    >," {>,",#

    {>,"

    >,# {>,# {>,"

    ",# {",# {

    >,",#

    {>,",#

    {>,"

    { { {

    Transition Diagra! O$ D%A

    2003

    > >,

    "

    >,",

    #

    >,#

  • 8/13/2019 MELJUN CORTES AUTOMATA Formal Language Lecture

    15/33

    Theory of Automata and

    Formal Language

    2002

    AUTOMATA THEORY PAGE1;

    ,O,'DETERM&,&ST&- %&,&TE AUTOMAT&O, B&TH I'MO0ES

    It is uintuple K = {L,,,>,- where the transition functions maps.

    :L x ; @ {< #L

    ;,a @ 0closure {"= {>,",# @ {",#= {>,",#

  • 8/13/2019 MELJUN CORTES AUTOMATA Formal Language Lecture

    16/33

  • 8/13/2019 MELJUN CORTES AUTOMATA Formal Language Lecture

    17/33

    Theory of Automata and

    Formal Language

    2002

    2003

    AUTOMATA THEORY' E2ui3aent ,%A o$ ,%A PAGE1@

    #. !onert the gien -Ato -A.

    - = {$,4 0closure ;>< = {>,",3> = {>= {a,b

    ,%A

    a % E

    > { { {",3

    " {",# " {

    # {$ { {

    $ {$ {$ {

    3 { {3 {

    4 { {4 {

    ,%A

    A b> {",# {",4

    " {",# {"

    # {$ >

    $ {$ {$

    3 { {4

    4 { {4

  • 8/13/2019 MELJUN CORTES AUTOMATA Formal Language Lecture

    18/33

    Theory of Automata and

    Formal Language

    2002

    2003

    AUTOMATA THEORY' E2ui3aent ,%A o$ ,%A PAGE1C

    - = {$,4

    Trans$or!ed ,%A

  • 8/13/2019 MELJUN CORTES AUTOMATA Formal Language Lecture

    19/33

    Theory of Automata and

    Formal Language

    2002

    2003

    AUTOMATA THEORY PAGE1

    REGULAR EJPRESS&O,S

    &E-III6: is an alphabet

    A regular expression oer is recursiely defined as:

    ". > is a regular expression denoting the set of {. #. is a regular expression denoting the set of {. $. -or any a, a is a regular expression denoting the set {a.

    3. If r,s,t are reg. exp. &enoting sets *,/, respectiely, then;r t s< denotes * u /rs denotes */r denotes *

    finite set of symbols

    '",'#,': set of strings from

    Examples:

    a. '"'#= { xyl x'"R S'# is the concatenation of '"9 '#e.g = {a,b

    '"= {a,b {}={} '#= {ba,a ={}

    '"'#= {a {ba {b {a = {aba,aa,bba,ba

    b. '>= { 'i= '' i)"

    e.g. ' = {>,"

    '>

    = {

    -ind '$'"= ''>= {>,",{

    = {>,"'#= ''"={>,"{>,"

    = {>>,>",">,""'$= ''#= {>,"{>>,>",">,""

    = {>>>,>>",>">,>"",">>,">","">,"""

  • 8/13/2019 MELJUN CORTES AUTOMATA Formal Language Lecture

    20/33

    Theory of Automata and

    Formal Language

    2002

    2003

    AUTOMATA THEORY'Reguar E#ressionsPAGE (

    KLEE,E -LOSUREof ' is defined as

    ' = @'i i = >

    POS&T&0E -LOSUREof ' is defined as

    'T = @'i i = >

    Example:' = {>,"

    ' = {e,>,",>>,"",">",>",">,""",>>>,">",H..'T = {>,",>>,"",">",>",">,""",>>>,">",HH.

    ' = {"' = {e,","",""","""",H..

    Examples: 'et = {>,"

    ". > = {>

    #. >" = {>"$. > T " = {>,"3. " = {e,","",""","""",HHH4. > T " = {e,>,",>>,>>>,HH... ">> = {>>,">>,"">>,""">>,H.C. ;>T",",>>,"",>>>,""",">,>",">",>>>"HHH.8. ;>>T">,","","""",>>>>",">>HH.D. ;>">T">"< = {e,>">,">",">"",">""",">""""HHH..">. ;>T"T"T"

  • 8/13/2019 MELJUN CORTES AUTOMATA Formal Language Lecture

    21/33

  • 8/13/2019 MELJUN CORTES AUTOMATA Formal Language Lecture

    22/33

    Theory of Automata and

    Formal Language

    2002

    2003

    AUTOMATA THEORY'Reguar E#ressionsPAGE ((

    #. >"

    $. >T"

    3. "

    4. ""T>

  • 8/13/2019 MELJUN CORTES AUTOMATA Formal Language Lecture

    23/33

    Theory of Automata and

    Formal Language

    2002

    2003

    AUTOMATA THEORY PAGE(

    -O,TEJT'%REE GRAMMARS

    !ontext0free Urammars describe context0free languages.

    *egular set is an example of !ontext -ree language.

    !ontext0-ree grammar ;!-U< is a uadruple

    U = ;J,,B,/< where J ) set of ariables {/,% ) set of terminals ;a,b,c>",.. J=/,%

    ={>," /=/

    B: / %" % >%

    %

    1 1

    / %" / %"

    1 >%" " >>%"

    >>>%" >>>1

    >>>"b. ;>T""s ""s

    >" """s >" """>s

    """>>s

    """>>"s

    """>>"

    """>>"

    c. ambn 1 mM= n

    / aKb K aKb 1 aK 1

    aabb aaabb

    / aKb / aKb

    aaKbb aaKbb

  • 8/13/2019 MELJUN CORTES AUTOMATA Formal Language Lecture

    25/33

    Theory of Automata and

    Formal Language

    2002

    aabb aaaKbb

    aabb aaabb

    aaabb

    2003

    AUTOMATA THEORY'-ontet %ree Gra!!arPAGE (;

    d. / | 0 | 1

    / "s" 1 >s>

    11 1

    / >s> / "s" / >s>

    >> ">" >>s>>

    >> >>">>

    e. ?an?bn? 1 nM=>

    aabb

    / a/b / a/b

    ab aa/bb ab aabb

    aabb

    f. set of integers ;T or 0 1 H 1 D 1 > 1 H 1 D

    1 'C@

    / T / 0

    T" 0D T"> 0D8

    0D8C

    g. {an

    bn

    cm

    dm

    1 n,m M > / abcd| aMbcNd

    K aKb 1

    ab 1

    aabbcd aabbccdd

    / aKbcd / aKbcd

    aaKbbcd aaKbbccdd

    aabbcd aabbccdd

  • 8/13/2019 MELJUN CORTES AUTOMATA Formal Language Lecture

    26/33

    Theory of Automata and

    Formal Language

    2002

    aabbcd aabbccdd

    2003

    AUTOMATA THEORY'-ontet %ree Gra!!arPAGE (=

    or

    / MN

    K aKb 1ab

    cd 1 cdaabbcd

    / K

    aKbcd

    aabbcd

    h. {xmyxm1 m M= >

    / x/x 1y

    " "

    / x/x / x/x xyx xx/xx

    xxx/xxx

    xxxyxxx

  • 8/13/2019 MELJUN CORTES AUTOMATA Formal Language Lecture

    27/33

    Theory of Automata and

    Formal Language

    2002

    2003

    AUTOMATA THEORY PAGE(@

    PUSHDOB, AUTOMATA

    !ontext -ree Urammars machine counterpart.(Just as the RE have anequivalent autometon-FA).

    on deterministic deice.(Deterministic version is only a suset o! all "F#$s). Vae input tape, finite control and a stac7

    Essentially a -A with control of both input and stac7 O-I'6P list.

    StacN ) is a string of symbols from some alphabet. he leftmost symbol of thestac7 is considered to be the OtapeP of the stac7.

    MO0ES". An input symbol is used.

    &epending on the input symbol, the top symbol on the stac7, and stateof the finite control, a number of choices are possible. Each choiceconsist of next state for the finite control and a ;possibly empty< stringof symbols to replace the top stac7 symbol. After selecting a choice,the input head is adanced one symbol.

    2. Input symbol is not used ;-moe). /imilar to the first except that the input symbol is not used and the

    input head is not adanced after the moe. Allows the B&A to manipulate the stac7 without reading input symbols.

    BAYS TO DE%&,E THE LA,GUAGE A--EPTED +Y PDA no final state ) emptyboth input tape 9 stac7

    ". /et of all inputs for which some seuence of moes causes the B&A to emptya stac7.

    #. &esignate some states as final sates define the accepted language as the set

    of all inputs for which some choice of moes causes the B&A to enter finalstate.

    with final state ) empty inputtape

    K = ;L, , , , o, Wo,-= in L, initial stateWo = in , start symbol- = X L, set of final states= mapping L x ;@ {}) ! to Q x *

    ;, a, W< = {;B", y"

  • 8/13/2019 MELJUN CORTES AUTOMATA Formal Language Lecture

    29/33

    Theory of Automata and

    Formal Language

    2002

    ;",>,%UU%%*< ; #, >, %* < ; #, , * < ; #, , < hold the input, which is a string ofsymbols chosen from a subset of the tape symbols called input

    symbols. he remaining infinity of cells each hold blan7, which is a special tape

    symbol that is not input symbol.

  • 8/13/2019 MELJUN CORTES AUTOMATA Formal Language Lecture

    30/33

    Theory of Automata and

    Formal Language

    2002

    -inite !ontrol

    +asic Turing Machine

    In one moe, the K ;%e&en%in' u&on the symol scanne% y th ta&e hea% thestate o! !inite control)

    ". changes state#. prints symbol on the tape cell scanned, replacing what was written there$. moes its head left or right one cell

    2003

    AUTOMATA THEORY'Turing Machine PAGE

    Language Acce#ted

    *ecursiely enumerable strings can be enumerated or listed by auring Kachine.

    Example: K = ;{o,"H3, {>,", {>,",x,y,%, , >,%, 3>""

    /tate Vead Bosition

    o >>"">" " x>"">" " x>"">" # x>y">" # x>y">" o x>y">" " xxy">" " xxy">"

    # xxyy>" # xxyy>" o xxyy>" $ xxyy>" $ xxyy>" Y

    herefore, not accepted

  • 8/13/2019 MELJUN CORTES AUTOMATA Formal Language Lecture

    32/33

    Theory of Automata and

    Formal Language

    2002

    2003

    AKA !6KB@E* @IJE*/ISBroject 8, Lue?on !ity

    !6''EUE 6- !6KB@E* /@&IE/

    KA@A'I

    A@6KAA VE6*S

    Brepared by :MELJUN . !"RTES

    K/!/ /@&E

  • 8/13/2019 MELJUN CORTES AUTOMATA Formal Language Lecture

    33/33

    Theory of Automata and

    Formal Language

    2002