SlideShare uma empresa Scribd logo
1 de 92
Non-regular languages
n n
                          {a b : n 0}
Non-regular languages
                             R
                          {ww : w {a, b}*}

            Regular languages
          a *b            b*c a
            b c ( a b) *
                 etc...
How can we prove that a language     L
is not regular?


Prove that there is no DFA that accepts   L

Problem: this is not easy to prove


Solution: the Pumping Lemma !!!
•        DFA with   4 states

                                 b
     b       b

    q1   a   q2 b       q3   b   q4
                    a        a
In walks of strings:   a          no state
                       aa         is repeated
 •                     aab


                                       b
        b        b

      q1    a   q2     a     q3   b   q4
                       a          a
In walks of strings:   aabb            a state
                                       is repeated
                       bbaa
  •
                       abbabb
                       abbbabbabb...
                                          b
        b        b

       q1    a   q2     a     q3   b     q4
                        a          a
In walks of strings:   aabb            a state
                                       is repeated
                       bbaa
  •
                       abbabb
                       abbbabbabb...
                                          b
        b        b

       q1    a   q2     a     q3   b     q4
                        a          a
If string w has length | w |    4:
•
     Then the transitions of string w
     are more than the states of the DFA

    Thus, a state must be repeated
                                     b
        b       b

       q1   a   q2   a   q3   b   q4
                     a        a
In general, for any DFA:

 String   w has length        number of states


A state   q must be repeated in the walk of w



  walk of   w
                 ......   q      ......
                   Repeated state
The Pumping Lemma
Take an infinite regular language L




         DFA that accepts   L


                                       m
                                      states
Take string   w with w L



     There is a walk with label   w:


                  .........
                walk   w
If string   w has length | w |       m      number
                                            of states
                                            of DFA
then, from the pigeonhole principle:

        a state   q is repeated in the walk w



                  ......       q   ......
                   walk    w
Let   q be the first state repeated




                ......       q   ......
                 walk    w
Write   w   xyz


                          y



                 ......   q   ......


             x                   z
Observations:       length   |x y|       m    number
                                              of states
                    length   | y|    1        of DFA


                              y



                    ......    q      ......


                x                        z
Observation:   The string       xz
               is accepted



                            y



                   ......   q    ......


               x                     z
Observation:   The string       xyyz
               is accepted



                            y



                   ......   q    ......


               x                    z
Observation:   The string       xyyyz
               is accepted



                            y



                   ......   q    ......


               x                    z
i
In General:   The string       xy z
              is accepted      i 0, 1, 2, ...


                           y



                  ......   q     ......


              x                        z
In General:        i              i      0, 1, 2, ...
              xy z          L
              The original language

                            y



                   ......   q   ......


               x                   z
In other words, we described:




    The Pumping Lemma !!!
The Pumping Lemma:

    • Given a infinite regular language           L
• there exists an integer m

• for any string   w L with length | w | m
• we can write     w       xyz

• with   |x y|         m   and       | y|   1
                       i
• such that:     xy z            L          i   0, 1, 2, ...
Theorem: The language
                             n n
                        L {a b : n 0}
                          is not regular




 Proof:   Use the Pumping Lemma
n n
    L {a b : n 0}


Assume for contradiction
that L is a regular language



Since L is infinite
we can apply the Pumping Lemma
n n
          L {a b : n 0}
Let   m be the integer in the Pumping Lemma


Pick a string   w such that: w   L
                            length   | w| m


                           m m
            We pick     w a b
m m
Write:    a b        xyz

From the Pumping Lemma
it must be that length | x     y | m, | y | 1
                           m           m
          m m
  xyz    a b         a...aa...aa...ab...b
                      x    y       z
                      k
         Thus:   y   a , k 1
m m                      k
    xyz     a b           y           a , k 1


                                      i
From the Pumping Lemma:       xy z              L
                              i       0, 1, 2, ...


                    2
          Thus:   xy z            L
m m                       k
    xyz    a b                  y   a , k 1

                                    2
From the Pumping Lemma:         xy z        L

                    m k                 m
      2
    xy z   a...aa...aa...aa...ab...b        L
              x     y       y       z

                  m k m
      Thus:   a         b       L
m   k       m
                a                b       L
       For all k > = 1



BUT:                 n n
          L {a b : n 0}


                    m k m
                a        b   L

        CONTRADICTION!!!
Therefore:   Our assumption that L      L
             is a regular language is
              not true




Conclusion: L is not a regular language
Non-regular language     n n
                       {a b : n 0}


            Regular languages
Non-regular languages           R
                        L {ww : w   *}


            Regular languages
Theorem: The language
                   R              {a, b}
          L {ww : w        *}
          is not regular




 Proof:   Use the Pumping Lemma
R
      L {ww : w        *}


Assume for contradiction
that L is a regular language



Since L is infinite
we can apply the Pumping Lemma
R
                L {ww : w     *}

Let   m be the integer in the Pumping Lemma


Pick a string   w such that: w     L   and

                             length    | w| m


                          m m m m
         We pick   w a b b a
m m m m
Write    a b b a         xyz

From the Pumping Lemma
it must be that length | x    y | m, | y | 1
                     m        m m m
         xyz   a...aa...a...ab...bb...ba...a
                x    y            z
                 k
 Thus:     y   a , k 1
m m m m                     k
xyz    a b b a            y       a , k 1



From the Pumping Lemma:       i
                          xy z            L
                          i       0, 1, 2, ...


                     2
           Thus:   xy z       L
m m m m                         k
xyz     a b b a                  y       a , k 1

                                     2
From the Pumping Lemma:      xy z            L

               m+k           m m m
 xy z = a...aa...aa...a...ab...bb...ba...a ∈ L
   2

          x    y     y           z

                    m k m m m
       Thus:    a        b b a           L
m k m m m
       a     b b a     L    k 1


BUT:            R
        L {ww : w      *}


           m k m m m
       a     b b a     L

       CONTRADICTION!!!
Therefore:   Our assumption that L
             is a regular language is not true




Conclusion: L is not a regular language
Non-regular languages
                        n l n l
                L {a b c          : n, l   0}


            Regular languages
Theorem: The language
                     n l n l
              L {a b c         : n, l   0}
          is not regular




 Proof:   Use the Pumping Lemma
n l n l
      L {a b c        : n, l   0}


Assume for contradiction
that L is a regular language



Since L is infinite
we can apply the Pumping Lemma
n l n l
            L {a b c          : n, l   0}
Let   m be the integer in the Pumping Lemma


Pick a string   w such that: w         L    and

                                length      | w| m



          We pick    w a b c  m m 2m
m m 2m
Write   a b c            xyz

From the Pumping Lemma
it must be that length | x     y | m, | y | 1

                        m          m       2m
        xyz       a...aa...aa...ab...bc...cc...c
                    x    y             z

Thus:         k
        y    a , k 1
m m 2m                   k
 xyz    a b c             y   a , k 1



From the Pumping Lemma:               i
                              xy z                L
                              i           0, 1, 2, ...


       Thus:              0
                   xy z               xz          L
m m 2m                     k
 xyz    a b c               y     a , k 1

From the Pumping Lemma:           xz       L
               m k        m       2m
       xz    a...aa...ab...bc...cc...c         L
               x              z

                       m k m 2m
       Thus:       a     b c               L
m k m 2m
        a      b c          L         k 1



BUT:          n l n l
       L {a b c         : n, l   0}


            m k m 2m
        a     b c          L

       CONTRADICTION!!!
Therefore:   Our assumption that L
             is a regular language is not true




Conclusion: L is not a regular language
Non-regular languages           n!
                         L {a : n 0}


            Regular languages
Example
L ={ w | w =0n where n is a perfect square}

  Let us assume that L is regular.
Use pumping Lemma
 Let m be the corresponding no. for pumping
   lemma.
  w = 0square of m
|w| >= m
 w = x y z where | x y| <= m; |y | >=1
Consider
   x yy z it should be in L
|xyyz| must be a perfect square
   but
 |xyyz| = m2 + |y| <= m2 + m
                       < m2 + m +m+1
                       = (m+1)2
 m2 < |xyyz |< (m+1)2
  so length of the string x yyz can not be a
   perfect square.
So it can not bea member of L. A
   contradiction! Hence L is non regular
Theorem: The language         n!
                        L {a : n 0}
                        is not regular


          n!   1 2  (n 1) n


Proof:   Use the Pumping Lemma
n!
      L {a : n 0}


Assume for contradiction
that L is a regular language



Since L is infinite
we can apply the Pumping Lemma
n!
            L {a : n 0}
Let   m be the integer in the Pumping Lemma


Pick a string   w such that: w       L
                                length   | w| m


                               m!
            We pick      w a
m!
Write     a         xyz

From the Pumping Lemma
it must be that length | x       y | m, | y | 1
                            m         m! m
               m!
    xyz   a           a...aa...aa...aa...aa...a
                        x   y          z
                             k
              Thus:    y    a , 1 k        m
m!              k
  xyz    a              y   a , 1 k              m



From the Pumping Lemma:          i
                            xy z             L
                             i       0, 1, 2, ...


          Thus:     2
                  xy z       L
m!                    k
  xyz    a                    y   a , 1 k       m

                                       2
From the Pumping Lemma:           xy z      L

                  m k              m! m
    2
 xy z   a...aa...aa...aa...aa...aa...a          L
          x       y       y        z

        Thus:         a   m! k
                                   L
m! k
         a           L            1 k   m

Since:          n!
         L {a : n 0}




   There must exist      p such that:
             m! k    p!
However:   m! k    m! m        for   m 1
                   m! m!
                   m!m m!
                   m!(m 1)
                   (m 1)!

            m! k   (m 1)!


            m! k    p!     for any   p
m! k       1 k   m
           a          L


              n!
BUT:   L {a : n 0}


              m! k
          a           L

       CONTRADICTION!!!
Therefore:   Our assumption that L
             is a regular language is not true




Conclusion: L is not a regular language
Minimization of Finite Automata
• State minimization problem

• There can be more than one DFA that
accepts the same language
 Among these equivalent DFAs, it is often
useful to find the smallest, that is, the DFA
with the minimum possible number of states

This is especially important when DFAs are
used for designing computer hardware
circuits
a,b

                    b
            1
                        3
        a
                a
0


    b                   4     b         5
            2
                b
        a                                   a
                        a,b
Equivalent finite automata




           a,b           b
      0              1
                                    2



                 a
                             a ,b
Unreachable states

 A DFA sometimes contains states that
cannot possibly be reached from the initial
  state
These can easily be identified and they
  can be removed without changing the
  language accepted by the DFA
Two states p and q of a dfa are
   indistinguishable if
    * (p, w)   F implies * (q,w ) F
And
   *(p, w)   F implies * (q,w) F
 for all w    * .

If on the other hand there exists some
   string w such that
  *(p,w) F and *(q,w) F

Or vice versa, then p and q are said to be
   distinguishable by a string w.
Procedure: mark
1- Remove all inaccessible states
2- Consider all pairs of states (p, q) .If
   p F and q F or vice versa mark the pair
   (p, q) as distinguishable.
3-Repeat the following step until no previously
  unmarked pairs are marked.
For all pairs (p, q) and all a     compute
    (p,a)=pa and (q,a) = qa .If (pa, qq) are
  distinguishable , mark (p, q) distinguishable.
Procedure Reduce
1- Use procedure mark to find all pairs of
  distinguishable states.Then from this,
  find the sets of all indistinguishable
  states , say{qi,qj…qk},{ql, qm …qn} etc,
2-For each set {qi,qj…qk} of such
  indistinguishable states, create a state
  labeled ij..k for the new machine M’
3-For each transition rule of M of the form
- (qr, a) = qp find the sets to which qr
  and qp belong.
If qp {ql, qm,…qn}
And qr (qi, qj,…qk} add to     ’   a rule

   ’ (ij…k, a) = lm…n
4- The initial state q0’ is that state of M’
  whose label includes the q0.initial state
  of M

5- F’ is the set of all states whose label
  contain I such that qi F
Example


                1                   0,1
        0
                            1
            0       0
0                       1       4
                2

    1               0

                            1
                3
Equivalent FA

                0       0,1


    0,1
0         123       1
                         4
0
                    1


            0
0               1       1
        1
                    2

    0
0
XX0,1

        1
0,1
XX0
Example
minimize
                                   4


           0                   1
                       0               0,1
     0         1           2

           0                       3
                   1
                                       0,1
                                        5

               1

                                             0,1
Minimal state FA

                         0,1
0


01                  35
         1
Example                        0

                               4
               0
        2
    0                          1               0
               1
1                              5



    1                      1
        3              0               0
                                   6
                                               1
                   1                   0
                                       7
                                               1
Min state FA


                1
  0


      1                     0
124       357
                                6

                        1


                    0
L1=       L3 = 1

                L5 =        *   01
 L2= 0

     *
L4 = 00              L7 =       *   11

          L6 = l =    *10
Lex
Lex: a lexical analyzer
• A Lex program recognizes strings



• For each kind of string found
  the lex program takes an action
Output
                              Identifier: Var
    Input                     Operand: =
Var = 12 + 9;                 Integer: 12
if (test > 20)                Operand: +
   temp = 0;                  Integer: 9
                    Lex       Semicolumn: ;
else
                    program
   while (a < 20)             Keyword: if
       temp++;                Parenthesis: (
                              Identifier: test
                              ....
In Lex strings are described
  with regular expressions

          Lex program
Regular expressions

    “+”
    “-”       /* operators */
    “=“

   “if”
              /* keywords */
   “then”
Lex program
Regular expressions

(0|1|2|3|4|5|6|7|8|9)+    /* integers */




(a|b|..|z|A|B|...|Z)+   /* identifiers */
Internal Structure of Lex

                Lex
Regular                           Minimal
              NFA      DFA
expressions                       DFA




    The final states of the DFA are
    associated with actions
Lex matches the longest input string


   Example: Regular Expressions        “if”
                                       “ifend”




  Input:    ifend       if       ifn

Matches:   “ifend”      “if”    nomatch
Input            Output

                   Integer
1234   test        Identifier
var 566       78   Identifier
9800 +             Integer
                   Integer
temp
                   Integer
                   Error in line: 3
                   Identifier

Mais conteúdo relacionado

Mais procurados

Mais procurados (20)

Finite automata examples
Finite automata examplesFinite automata examples
Finite automata examples
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
 
Finite Automata
Finite AutomataFinite Automata
Finite Automata
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
 
Theory of computing
Theory of computingTheory of computing
Theory of computing
 
Formal Languages and Automata Theory Unit 1
Formal Languages and Automata Theory Unit 1Formal Languages and Automata Theory Unit 1
Formal Languages and Automata Theory Unit 1
 
Automata theory
Automata theoryAutomata theory
Automata theory
 
0 1 knapsack using branch and bound
0 1 knapsack using branch and bound0 1 knapsack using branch and bound
0 1 knapsack using branch and bound
 
NP completeness
NP completenessNP completeness
NP completeness
 
Pumping lemma for regular set h1
Pumping lemma for regular set h1Pumping lemma for regular set h1
Pumping lemma for regular set h1
 
Ambiguous & Unambiguous Grammar
Ambiguous & Unambiguous GrammarAmbiguous & Unambiguous Grammar
Ambiguous & Unambiguous Grammar
 
Deterministic Finite Automata (DFA)
Deterministic Finite Automata (DFA)Deterministic Finite Automata (DFA)
Deterministic Finite Automata (DFA)
 
closure properties of regular language.pptx
closure properties of regular language.pptxclosure properties of regular language.pptx
closure properties of regular language.pptx
 
TOC 3 | Different Operations on DFA
TOC 3 | Different Operations on DFATOC 3 | Different Operations on DFA
TOC 3 | Different Operations on DFA
 
NFA & DFA
NFA & DFANFA & DFA
NFA & DFA
 
Chomsky classification of Language
Chomsky classification of LanguageChomsky classification of Language
Chomsky classification of Language
 
Graph algorithm
Graph algorithmGraph algorithm
Graph algorithm
 
Alphabets , strings, languages and grammars
Alphabets , strings, languages  and grammarsAlphabets , strings, languages  and grammars
Alphabets , strings, languages and grammars
 
Context free grammar
Context free grammar Context free grammar
Context free grammar
 
Optimal binary search tree dynamic programming
Optimal binary search tree   dynamic programmingOptimal binary search tree   dynamic programming
Optimal binary search tree dynamic programming
 

Destaque

Pumping Lemma
Pumping LemmaPumping Lemma
Pumping Lemmaeburhan
 
Formal methods 2 - languages and machines
Formal methods   2 - languages and machinesFormal methods   2 - languages and machines
Formal methods 2 - languages and machinesVlad Patryshev
 
0227 regularlanguages
 0227 regularlanguages 0227 regularlanguages
0227 regularlanguagesissbp
 
Pumping lemma for regular language
Pumping lemma for regular languagePumping lemma for regular language
Pumping lemma for regular languagesadique_ghitm
 
Class6
 Class6 Class6
Class6issbp
 
Introduction to fa and dfa
Introduction to fa  and dfaIntroduction to fa  and dfa
Introduction to fa and dfadeepinderbedi
 
Lecture: Regular Expressions and Regular Languages
Lecture: Regular Expressions and Regular LanguagesLecture: Regular Expressions and Regular Languages
Lecture: Regular Expressions and Regular LanguagesMarina Santini
 

Destaque (10)

Pumping Lemma
Pumping LemmaPumping Lemma
Pumping Lemma
 
Pumping Lemma
Pumping LemmaPumping Lemma
Pumping Lemma
 
Pumping lemma
Pumping lemmaPumping lemma
Pumping lemma
 
Formal methods 2 - languages and machines
Formal methods   2 - languages and machinesFormal methods   2 - languages and machines
Formal methods 2 - languages and machines
 
SLIDE KE:5 NFA
SLIDE KE:5 NFASLIDE KE:5 NFA
SLIDE KE:5 NFA
 
0227 regularlanguages
 0227 regularlanguages 0227 regularlanguages
0227 regularlanguages
 
Pumping lemma for regular language
Pumping lemma for regular languagePumping lemma for regular language
Pumping lemma for regular language
 
Class6
 Class6 Class6
Class6
 
Introduction to fa and dfa
Introduction to fa  and dfaIntroduction to fa  and dfa
Introduction to fa and dfa
 
Lecture: Regular Expressions and Regular Languages
Lecture: Regular Expressions and Regular LanguagesLecture: Regular Expressions and Regular Languages
Lecture: Regular Expressions and Regular Languages
 

Mais de lavishka_anuj

Mais de lavishka_anuj (10)

Simplifiaction of grammar
Simplifiaction of grammarSimplifiaction of grammar
Simplifiaction of grammar
 
Properties of cfg
Properties of cfgProperties of cfg
Properties of cfg
 
One ques
One quesOne ques
One ques
 
Moore and mealy machines
Moore and mealy machinesMoore and mealy machines
Moore and mealy machines
 
Grammar
GrammarGrammar
Grammar
 
Flat
FlatFlat
Flat
 
Finite automata intro
Finite automata introFinite automata intro
Finite automata intro
 
Finite automata
Finite automataFinite automata
Finite automata
 
Pushdown automata
Pushdown automataPushdown automata
Pushdown automata
 
Turing machines
Turing machinesTuring machines
Turing machines
 

Último

Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 

Último (20)

Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 

Non regular languages

  • 2. n n {a b : n 0} Non-regular languages R {ww : w {a, b}*} Regular languages a *b b*c a b c ( a b) * etc...
  • 3. How can we prove that a language L is not regular? Prove that there is no DFA that accepts L Problem: this is not easy to prove Solution: the Pumping Lemma !!!
  • 4. DFA with 4 states b b b q1 a q2 b q3 b q4 a a
  • 5. In walks of strings: a no state aa is repeated • aab b b b q1 a q2 a q3 b q4 a a
  • 6. In walks of strings: aabb a state is repeated bbaa • abbabb abbbabbabb... b b b q1 a q2 a q3 b q4 a a
  • 7. In walks of strings: aabb a state is repeated bbaa • abbabb abbbabbabb... b b b q1 a q2 a q3 b q4 a a
  • 8. If string w has length | w | 4: • Then the transitions of string w are more than the states of the DFA Thus, a state must be repeated b b b q1 a q2 a q3 b q4 a a
  • 9. In general, for any DFA: String w has length number of states A state q must be repeated in the walk of w walk of w ...... q ...... Repeated state
  • 11. Take an infinite regular language L DFA that accepts L m states
  • 12. Take string w with w L There is a walk with label w: ......... walk w
  • 13. If string w has length | w | m number of states of DFA then, from the pigeonhole principle: a state q is repeated in the walk w ...... q ...... walk w
  • 14. Let q be the first state repeated ...... q ...... walk w
  • 15. Write w xyz y ...... q ...... x z
  • 16. Observations: length |x y| m number of states length | y| 1 of DFA y ...... q ...... x z
  • 17. Observation: The string xz is accepted y ...... q ...... x z
  • 18. Observation: The string xyyz is accepted y ...... q ...... x z
  • 19. Observation: The string xyyyz is accepted y ...... q ...... x z
  • 20. i In General: The string xy z is accepted i 0, 1, 2, ... y ...... q ...... x z
  • 21. In General: i i 0, 1, 2, ... xy z L The original language y ...... q ...... x z
  • 22. In other words, we described: The Pumping Lemma !!!
  • 23. The Pumping Lemma: • Given a infinite regular language L • there exists an integer m • for any string w L with length | w | m • we can write w xyz • with |x y| m and | y| 1 i • such that: xy z L i 0, 1, 2, ...
  • 24. Theorem: The language n n L {a b : n 0} is not regular Proof: Use the Pumping Lemma
  • 25. n n L {a b : n 0} Assume for contradiction that L is a regular language Since L is infinite we can apply the Pumping Lemma
  • 26. n n L {a b : n 0} Let m be the integer in the Pumping Lemma Pick a string w such that: w L length | w| m m m We pick w a b
  • 27. m m Write: a b xyz From the Pumping Lemma it must be that length | x y | m, | y | 1 m m m m xyz a b a...aa...aa...ab...b x y z k Thus: y a , k 1
  • 28. m m k xyz a b y a , k 1 i From the Pumping Lemma: xy z L i 0, 1, 2, ... 2 Thus: xy z L
  • 29. m m k xyz a b y a , k 1 2 From the Pumping Lemma: xy z L m k m 2 xy z a...aa...aa...aa...ab...b L x y y z m k m Thus: a b L
  • 30. m k m a b L For all k > = 1 BUT: n n L {a b : n 0} m k m a b L CONTRADICTION!!!
  • 31. Therefore: Our assumption that L L is a regular language is not true Conclusion: L is not a regular language
  • 32. Non-regular language n n {a b : n 0} Regular languages
  • 33. Non-regular languages R L {ww : w *} Regular languages
  • 34. Theorem: The language R {a, b} L {ww : w *} is not regular Proof: Use the Pumping Lemma
  • 35. R L {ww : w *} Assume for contradiction that L is a regular language Since L is infinite we can apply the Pumping Lemma
  • 36. R L {ww : w *} Let m be the integer in the Pumping Lemma Pick a string w such that: w L and length | w| m m m m m We pick w a b b a
  • 37. m m m m Write a b b a xyz From the Pumping Lemma it must be that length | x y | m, | y | 1 m m m m xyz a...aa...a...ab...bb...ba...a x y z k Thus: y a , k 1
  • 38. m m m m k xyz a b b a y a , k 1 From the Pumping Lemma: i xy z L i 0, 1, 2, ... 2 Thus: xy z L
  • 39. m m m m k xyz a b b a y a , k 1 2 From the Pumping Lemma: xy z L m+k m m m xy z = a...aa...aa...a...ab...bb...ba...a ∈ L 2 x y y z m k m m m Thus: a b b a L
  • 40. m k m m m a b b a L k 1 BUT: R L {ww : w *} m k m m m a b b a L CONTRADICTION!!!
  • 41. Therefore: Our assumption that L is a regular language is not true Conclusion: L is not a regular language
  • 42. Non-regular languages n l n l L {a b c : n, l 0} Regular languages
  • 43. Theorem: The language n l n l L {a b c : n, l 0} is not regular Proof: Use the Pumping Lemma
  • 44. n l n l L {a b c : n, l 0} Assume for contradiction that L is a regular language Since L is infinite we can apply the Pumping Lemma
  • 45. n l n l L {a b c : n, l 0} Let m be the integer in the Pumping Lemma Pick a string w such that: w L and length | w| m We pick w a b c m m 2m
  • 46. m m 2m Write a b c xyz From the Pumping Lemma it must be that length | x y | m, | y | 1 m m 2m xyz a...aa...aa...ab...bc...cc...c x y z Thus: k y a , k 1
  • 47. m m 2m k xyz a b c y a , k 1 From the Pumping Lemma: i xy z L i 0, 1, 2, ... Thus: 0 xy z xz L
  • 48. m m 2m k xyz a b c y a , k 1 From the Pumping Lemma: xz L m k m 2m xz a...aa...ab...bc...cc...c L x z m k m 2m Thus: a b c L
  • 49. m k m 2m a b c L k 1 BUT: n l n l L {a b c : n, l 0} m k m 2m a b c L CONTRADICTION!!!
  • 50. Therefore: Our assumption that L is a regular language is not true Conclusion: L is not a regular language
  • 51. Non-regular languages n! L {a : n 0} Regular languages
  • 52. Example L ={ w | w =0n where n is a perfect square} Let us assume that L is regular. Use pumping Lemma Let m be the corresponding no. for pumping lemma. w = 0square of m |w| >= m w = x y z where | x y| <= m; |y | >=1
  • 53. Consider x yy z it should be in L |xyyz| must be a perfect square but |xyyz| = m2 + |y| <= m2 + m < m2 + m +m+1 = (m+1)2 m2 < |xyyz |< (m+1)2 so length of the string x yyz can not be a perfect square. So it can not bea member of L. A contradiction! Hence L is non regular
  • 54. Theorem: The language n! L {a : n 0} is not regular n! 1 2  (n 1) n Proof: Use the Pumping Lemma
  • 55. n! L {a : n 0} Assume for contradiction that L is a regular language Since L is infinite we can apply the Pumping Lemma
  • 56. n! L {a : n 0} Let m be the integer in the Pumping Lemma Pick a string w such that: w L length | w| m m! We pick w a
  • 57. m! Write a xyz From the Pumping Lemma it must be that length | x y | m, | y | 1 m m! m m! xyz a a...aa...aa...aa...aa...a x y z k Thus: y a , 1 k m
  • 58. m! k xyz a y a , 1 k m From the Pumping Lemma: i xy z L i 0, 1, 2, ... Thus: 2 xy z L
  • 59. m! k xyz a y a , 1 k m 2 From the Pumping Lemma: xy z L m k m! m 2 xy z a...aa...aa...aa...aa...aa...a L x y y z Thus: a m! k L
  • 60. m! k a L 1 k m Since: n! L {a : n 0} There must exist p such that: m! k p!
  • 61. However: m! k m! m for m 1 m! m! m!m m! m!(m 1) (m 1)! m! k (m 1)! m! k p! for any p
  • 62. m! k 1 k m a L n! BUT: L {a : n 0} m! k a L CONTRADICTION!!!
  • 63. Therefore: Our assumption that L is a regular language is not true Conclusion: L is not a regular language
  • 65. • State minimization problem • There can be more than one DFA that accepts the same language Among these equivalent DFAs, it is often useful to find the smallest, that is, the DFA with the minimum possible number of states This is especially important when DFAs are used for designing computer hardware circuits
  • 66. a,b b 1 3 a a 0 b 4 b 5 2 b a a a,b
  • 67. Equivalent finite automata a,b b 0 1 2 a a ,b
  • 68. Unreachable states A DFA sometimes contains states that cannot possibly be reached from the initial state These can easily be identified and they can be removed without changing the language accepted by the DFA
  • 69.
  • 70.
  • 71.
  • 72. Two states p and q of a dfa are indistinguishable if * (p, w) F implies * (q,w ) F And *(p, w) F implies * (q,w) F for all w * . If on the other hand there exists some string w such that *(p,w) F and *(q,w) F Or vice versa, then p and q are said to be distinguishable by a string w.
  • 73. Procedure: mark 1- Remove all inaccessible states 2- Consider all pairs of states (p, q) .If p F and q F or vice versa mark the pair (p, q) as distinguishable. 3-Repeat the following step until no previously unmarked pairs are marked. For all pairs (p, q) and all a compute (p,a)=pa and (q,a) = qa .If (pa, qq) are distinguishable , mark (p, q) distinguishable.
  • 74. Procedure Reduce 1- Use procedure mark to find all pairs of distinguishable states.Then from this, find the sets of all indistinguishable states , say{qi,qj…qk},{ql, qm …qn} etc, 2-For each set {qi,qj…qk} of such indistinguishable states, create a state labeled ij..k for the new machine M’ 3-For each transition rule of M of the form - (qr, a) = qp find the sets to which qr and qp belong.
  • 75. If qp {ql, qm,…qn} And qr (qi, qj,…qk} add to ’ a rule ’ (ij…k, a) = lm…n 4- The initial state q0’ is that state of M’ whose label includes the q0.initial state of M 5- F’ is the set of all states whose label contain I such that qi F
  • 76. Example 1 0,1 0 1 0 0 0 1 4 2 1 0 1 3
  • 77. Equivalent FA 0 0,1 0,1 0 123 1 4
  • 78. 0 1 0 0 1 1 1 2 0
  • 79. 0 XX0,1 1 0,1 XX0
  • 80. Example minimize 4 0 1 0 0,1 0 1 2 0 3 1 0,1 5 1 0,1
  • 81. Minimal state FA 0,1 0 01 35 1
  • 82. Example 0 4 0 2 0 1 0 1 1 5 1 1 3 0 0 6 1 1 0 7 1
  • 83. Min state FA 1 0 1 0 124 357 6 1 0
  • 84. L1= L3 = 1 L5 = * 01 L2= 0 * L4 = 00 L7 = * 11 L6 = l = *10
  • 85. Lex
  • 86. Lex: a lexical analyzer • A Lex program recognizes strings • For each kind of string found the lex program takes an action
  • 87. Output Identifier: Var Input Operand: = Var = 12 + 9; Integer: 12 if (test > 20) Operand: + temp = 0; Integer: 9 Lex Semicolumn: ; else program while (a < 20) Keyword: if temp++; Parenthesis: ( Identifier: test ....
  • 88. In Lex strings are described with regular expressions Lex program Regular expressions “+” “-” /* operators */ “=“ “if” /* keywords */ “then”
  • 89. Lex program Regular expressions (0|1|2|3|4|5|6|7|8|9)+ /* integers */ (a|b|..|z|A|B|...|Z)+ /* identifiers */
  • 90. Internal Structure of Lex Lex Regular Minimal NFA DFA expressions DFA The final states of the DFA are associated with actions
  • 91. Lex matches the longest input string Example: Regular Expressions “if” “ifend” Input: ifend if ifn Matches: “ifend” “if” nomatch
  • 92. Input Output Integer 1234 test Identifier var 566 78 Identifier 9800 + Integer Integer temp Integer Error in line: 3 Identifier