Pushdown Automaton (PDA) Example: {0^n 1^n}

Поділитися
Вставка
  • Опубліковано 23 жов 2020
  • Here we derive a PDA for the infamous non-regular language {0^n 1^n : n at least 0}. We give some tips as well for how to solve other PDAs. The general aspect here is to "match" 0s with 1s by pushing 0s onto the stack, and popping the 1s in tandem. There is some complication with popping an empty stack, so we push a "dummy" character on the stack to detect when the matching has concluded to avoid this problem.
    What is a pushdown automaton? It is a finite state machine, where on each transition, items can be pushed or popped off of a stack it has, which has unlimited height. See • What is a Pushdown Aut... for more details.
    ▶ABOUT ME◀
    I am a professor of Computer Science, and am passionate about CS theory. I have taught many courses at several different universities, including several sections of undergraduate and graduate theory-level classes.

КОМЕНТАРІ • 54

  • @tonyjaimep
    @tonyjaimep 3 роки тому +20

    Explains in 10 minutes what my professor took two hours to skim over, thank you!

    • @EasyTheory
      @EasyTheory  3 роки тому +10

      I wouldn't discount another professor that easily, but thanks anyway!

  • @hamedpanjeh3947
    @hamedpanjeh3947 3 роки тому +15

    Indeed, awesome explanation in a very short time is an art! recording date of this video tells me I am super lucky to have such rich resource on the exact time! Thank you Ryan!

  • @AlexReyesInHD
    @AlexReyesInHD 3 роки тому +22

    Thank you for these videos! They're really helpful for me to understand theory of computation. The amazing work you're doing it helping out many students!

  • @Kevin-bb7wk
    @Kevin-bb7wk Рік тому +1

    Ryan your videos are saving my bacon in my Models of Computation class. You're the man!

  • @mahesh_bvn
    @mahesh_bvn Рік тому

    great video mate keep going. Much love!!!

  • @ianskinner3426
    @ianskinner3426 8 місяців тому

    Thank you so much. Very clear and exactly what I needed to understand this

  • @user-ln6hz2nb7o
    @user-ln6hz2nb7o Рік тому

    that triple e transition was good point
    thank you.

  • @Taayjus
    @Taayjus 9 місяців тому

    thank you so so much! I don't pay attention in class and just look for your video on the topic before the quiz and I've passed all of them

  • @vimalathithand917
    @vimalathithand917 7 місяців тому +1

    thank you for such a simple and easy to understand video :D

  • @slhx8956
    @slhx8956 2 роки тому

    This is a great video. Thank you so much

  • @CornelliusTrivium-gl9lt
    @CornelliusTrivium-gl9lt 2 місяці тому +1

    Incredible explanation

  • @stijnjongbloed1
    @stijnjongbloed1 Рік тому

    Thanks for the video!

  • @sarudesu2883
    @sarudesu2883 3 роки тому

    very helpful, thank you :)

  • @brianna1347
    @brianna1347 3 роки тому

    Thank you so much!

  • @omar.alnounou
    @omar.alnounou 2 роки тому

    i stopped mid-video just to say THANK YOU

  • @samjudelson
    @samjudelson 2 роки тому

    Thanks!

  • @sravanikatasani6502
    @sravanikatasani6502 3 роки тому

    Thank you Ryan sir😊

  • @artmissgns8315
    @artmissgns8315 2 роки тому

    great video

  • @rizzbod
    @rizzbod 7 місяців тому

    Thanks a much!

  • @unordinary27
    @unordinary27 2 роки тому

    thank you for the video! it was really helpful.

  • @muratpinkman9679
    @muratpinkman9679 Рік тому

    thank you

  • @jonathancohen7653
    @jonathancohen7653 3 роки тому +1

    Excellent

  • @sravanikatasani6502
    @sravanikatasani6502 3 роки тому +8

    Can you just put up a worksheet kinda thing ,that'll be great i feel

  • @ketchupkrill
    @ketchupkrill 9 місяців тому

    Can you do both loops for 1 and 0 on the same state? Or do you have to have a seperate state to do each

  • @iuseyoutubealot
    @iuseyoutubealot 3 місяці тому

    so how come no q loop here or thats for cfg

  • @kudakwashejuniormuzenda5432
    @kudakwashejuniormuzenda5432 3 роки тому

    helpful indeed

  • @charlesroseman9466
    @charlesroseman9466 2 роки тому +2

    Would q0 also be an accept state since 0^n1^n can be an empty string? I know that the empty string is able to go through every state, but I'm just curious if it's appropriate to also make q0 an accept state.

    • @EasyTheory
      @EasyTheory  2 роки тому +3

      It can, but no need, since there is a way for empty input to make its way through the machine as-is.

    • @charlesroseman9466
      @charlesroseman9466 2 роки тому +3

      @@EasyTheory Okay. Just making sure cuz my professor is a hardass and will probably take credit away for something like that lol. Thanks for the video! Very helpful.

    • @farwahbatool6247
      @farwahbatool6247 2 роки тому +1

      @@charlesroseman9466 lol

  • @TheSpruut
    @TheSpruut 3 роки тому +3

    if the stack needs to be empty to be accepted, why the need for the $ symbol, even without the $ symbol if the input will only finish if there are as many (or more) 1's to 0's and the stack will only empty if there are as many (or more) 0's to 1's so the number of 0's and 1's will need to be the same and no $ should be needed?

    • @farwahbatool6247
      @farwahbatool6247 2 роки тому

      that way we would not know that the PDA's stack is empty. It's like putting a slab over void to ensure that we're standing on rock bottom 😛

  • @0x44Monad
    @0x44Monad 4 місяці тому

    2 stack pushdown automata?

  • @sayantaniguha8519
    @sayantaniguha8519 2 роки тому

    Instead of that E-transition b/w q1 & q2 ,
    Can we make the initial state final & write that transition as *1,0->E* ?

    • @zahidgul5811
      @zahidgul5811 2 роки тому

      then you wouldn't be able to pop $ sign. Which is on stack.

    • @Elrog3
      @Elrog3 Рік тому

      @@zahidgul5811 the $ isn't on the stack at q0. Its onlt on the stack after you go to q1.

    • @Elrog3
      @Elrog3 Рік тому

      Yes. That is how the PDA for this language is shown in the textbook I am using.

  • @Nikifuj908
    @Nikifuj908 2 роки тому

    Hey, I keep following the automaton you drew to verify that it rejects "10". But it keeps landing on the accepting state q3. Am I doing something wrong?
    Stack: [], String: "10", State: q0
    Stack: [$], String: "10", State: q1
    Stack: [$], String: "10", State: q2
    Stack: [], String: "10", State: q3 (accepting)
    Or do you have to exhaust the entire input string for it to accept?

    • @Edigor100
      @Edigor100 2 роки тому

      yes he said that at the end, the entire input has to be read in order for it to be able to accept.

  • @rafaela2400
    @rafaela2400 3 роки тому +1

    stupid question but here it goes: If we wanted could we pop off all the 1's at q2, but twice as fast? Meaning if I wanted to have 0^n and 1^2n, could i just have the same thing as your pda, but instead at q2, pop off (11,0) instead of (1,0)? Thank you so much for your tutorials! they are amazing.

    • @EasyTheory
      @EasyTheory  3 роки тому +5

      No such thing as a stupid question if you really want to know the answer :)
      Yes, but only if the language is {0^n 1^(2n) : n at least 0}. If you wanted to apply this to {0^n 1^n : n at least 0} (note the difference in the 1 exponent), then this won't work whenever the input string has n being odd. But if you instead insisted that n be even, then yes you could.
      The only "problem" is that the PDA definition only allows one character to be read/popped/whatever in one transition. You can augment the definition to an "extended" PDA, where more than one can occur at once. This is usually done on the stack, not the input though.
      And thanks for watching!

    • @rafaela2400
      @rafaela2400 3 роки тому +1

      @@EasyTheory Many thanks for your answer and even more thanks for putting out such great content!!

  • @andrewliao1351
    @andrewliao1351 2 роки тому

    9:02 why can't you take that transition? You have read the whole input and it is trying to read epsilon.

    • @moatef1886
      @moatef1886 2 роки тому

      You can't take that transition because look at what is required to pop off the stack in order to take it? You must be able to pop off the $ symbol from the stack but...the $ is not at the top of the stack! A 0 will be on the top of the stack after you have read all the 0s and all the 1s in the case of there being more 0s than 1s.
      So yes, epsilon can be read but you cannot pop something off the stack if it is not at the top of the stack.

  • @lukesmith9289
    @lukesmith9289 2 роки тому +1

    why do # of 0s and 1s need to be equal?

    • @moatef1886
      @moatef1886 2 роки тому

      That's the definition of the language we are working with. So that's kind of a given, and we're just designing a machine that recognizes that language

  • @Fahodinho
    @Fahodinho 2 роки тому +1

    cheers mate

  • @Yenaled1
    @Yenaled1 Рік тому

    the other type of PDA would be a lot more fun than this