Conversion of NFA to DFA (Powerset/Subset Construction Example)

Sdílet
Vložit
  • čas přidán 10. 07. 2024
  • Here we convert a simple NFA with four states into an equivalent DFA. We first compute the epsilon-closure of the start state, and then make that the start state of the DFA. Then we "build states as needed" until we "complete" the DFA (i.e., every transition needed is present). And lastly, the final states of the DFA are the ones where the set of states contains a final state from the NFA. In our example, we ended up generating 9 states out of the possible 16.
    I also give advice on how to easily convert any NFA into an equivalent DFA, and what steps are needed at each point. Note that the process does not require intuition, but rather computing which states should be included.
    What is a nondeterministic finite automaton (NFA)? It is a finite state machine, with "states" and transitions between them, allowing choices as compared to a deterministic FA. See • What is an Nondetermin... for more details.
    Timestamps:
    0:00 - Intro
    0:12 - Guidelines
    0:47 - Epsilon closure of {q0}
    1:45 - Transitions for {q0}
    3:14 - Transitions for {q2}
    4:25 - Transitions for {q3} + "dead" state
    5:19 - Transitions for {q1}
    6:05 - Transitions for {q1,q2}
    7:21 - Transitions for {q2,q3}
    7:50 - Transitions for {q1,q3}
    9:05 - Transitions for {q0,q1,q2}
    10:10 - Final States
    11:25 - Conclusion
    If you like this content, please consider subscribing to my channel: / @easytheory
    ▶ADDITIONAL QUESTIONS◀
    1. The DFA we generated had 9 states, where there are 16 possible subsets of 4 states. What happened to the other 7?
    2. Can you create an NFA such that the corresponding DFA must have all possible states?
    3. Same as Question 2, but where the NFA has no epsilon transitions.
    ▶SEND ME THEORY QUESTIONS◀
    ryan.e.dougherty@icloud.com
    ▶ABOUT ME◀
    I am a professor of Computer Science, and am passionate about CS theory. I have taught over 12 courses at Arizona State University, as well as Colgate University, including several sections of undergraduate theory.

Komentáře • 79

  • @EasyTheory
    @EasyTheory  Před 4 lety +4

    Next video! Proving that {0^n 1^n : n at least 0} is not regular: czcams.com/video/5GG8goBW9gw/video.html

  • @JayashreeAPElumalai

    Thank you soo much. Had to study this for finals and I was confused by my own notes. After many vids yours was the only one that answered all my confusions.

  • @aokellermann
    @aokellermann Před 4 lety +95

    Thank you so much man. You're way more competent than my university professor.

  • @hectorg362
    @hectorg362 Před 3 lety +34

    I personally like this version better than the version where you are building a table of transition states and then drawing out the DFA with that table.

    • @wasgehdabman
      @wasgehdabman Před 5 měsíci

      it's the same thing though, just with the table you keep track of everything. With a larger alphabet it could get messy.

  • @bachi5373
    @bachi5373 Před 2 lety +17

    A lot of videos didn't include the empty string Epsilon. This helps a lot!

  • @hurboglan1003
    @hurboglan1003 Před rokem +1

    my lecture notes look like alien language but this thing right here, anybody could understand this. Thank you so much

  • @2v2
    @2v2 Před 7 měsíci

    Really took all the complex mind bending gymnastics out of it thank you.

  • @thelogbob281
    @thelogbob281 Před rokem +1

    incredible, incredible video! thank you so much for doing what my textbook could not which would be explaining this process in a simple yet explanatory manner. Have a great day!

  • @yitooasrat4668
    @yitooasrat4668 Před 2 lety +2

    keep up the good work
    This is a the best explanation anyone can get on this course

  • @kevalgandhi1272
    @kevalgandhi1272 Před rokem

    Thank you SO MUCH for your explanation, I got this concept literally just now!! Thanks a lot!

  • @dionysismaniatakosmusic

    Thanks! You did a great job explaining it!

  • @manalasmouh5549
    @manalasmouh5549 Před 5 měsíci +1

    I’m glad i came across this channel cuz my teacher sucks

  • @saladrockstar
    @saladrockstar Před 9 měsíci

    Super helpful for my discrete 2 exam this week! Thanks so much :D

  • @IncendiaHL
    @IncendiaHL Před rokem

    Ok this seemed so difficult in class, but you made it easy. Thank you!!

  • @charlie10010
    @charlie10010 Před rokem

    Holy crap this method is so beautiful! Thanks!!!

  • @amesund
    @amesund Před 4 lety +4

    Your videos are so helpful, thank you!

  • @user-bj6rf8fx4i
    @user-bj6rf8fx4i Před 6 měsíci

    Wow! Congrats on the clear explaination

  • @edgermoreno3945
    @edgermoreno3945 Před 3 lety +8

    Amazing job, you make solving these problems much easier.

  • @abel5545
    @abel5545 Před 4 lety +2

    This was very easy to follow. Thanks a lot :)

  • @TotallyOKAYProductions

    this is some good stuff bro

  • @breakloop
    @breakloop Před 10 měsíci +2

    i get uni's might have to stick with teaching the most 'formal/textbook' ways of solving a problem. but being taught these hacky but intuitive methods would make overall comprehension such a breeze and personally i think that's what education should be about.

  • @kenana3456
    @kenana3456 Před 2 lety

    Great explanation , thanks

  • @ahmetmurtezaoglu
    @ahmetmurtezaoglu Před 4 měsíci

    Thank you a lot, great work!

  • @stevehof
    @stevehof Před 2 lety

    Thanks a bunch! Super clear!

  • @anarmehraliyev1286
    @anarmehraliyev1286 Před 3 lety

    Thanks a lot, I finally got it

  • @user-cl6pr1jy9s
    @user-cl6pr1jy9s Před 3 měsíci

    very good video, love it

  • @enisozer5007
    @enisozer5007 Před rokem

    Great content!

  • @javawithhawa
    @javawithhawa Před 2 lety

    Great video!

  • @aahilrafiq4850
    @aahilrafiq4850 Před 7 měsíci

    Thank you , i understood really well !

  • @booqueefiusbartholomuleiii9957

    Thanks for this great video

  • @nyanyacalc
    @nyanyacalc Před rokem

    Nice explanation, thanks

  • @cameronfrazier8330
    @cameronfrazier8330 Před 3 měsíci

    LITERALLY PERFEECT VIDEO

  • @britannio
    @britannio Před 2 lety

    Legendary video

  • @glizzy5154
    @glizzy5154 Před rokem

    needed this

  • @manalasmouh5549
    @manalasmouh5549 Před 4 měsíci

    best teacher evaaah

  • @jiwooahn1966
    @jiwooahn1966 Před 3 měsíci

    thanks a lot! u just saved my mid

  • @isam3l3
    @isam3l3 Před 3 lety

    Thanks, along side this. Wikipedia helped me grasp the theoretical side a little aswell

  • @shanestevens516
    @shanestevens516 Před 2 lety

    way better than my professor!

  • @memoymishra4619
    @memoymishra4619 Před rokem

    C'est incroyable!

  • @helcomn
    @helcomn Před rokem +1

    Thanks! In the end i was left with only one final state and it was the one that i started with. I checked my DFA and there was no route starting from my ε-enclosure and getting back there, so I assumed it was alright. I'd be happy to hear from your side to see if i did anything questionable.
    P.S i didnt go to my uni class but you seem superior.

  • @selinamartinez8067
    @selinamartinez8067 Před rokem

    I'm always watching your video! And it is the most awesome lecture I've ever seen since I was born!!!! Thank you SOOOO much!!!!

  • @andreymarchuk8938
    @andreymarchuk8938 Před 2 lety

    Thank you!

  • @azuboof
    @azuboof Před rokem

    youre awesome. thanks

  • @zacklnwza0073
    @zacklnwza0073 Před rokem

    you the best.

  • @adityamishra6389
    @adityamishra6389 Před 2 lety

    Thanks man.

  • @1SnowBall1
    @1SnowBall1 Před rokem

    really late to this gem but thank you! I have a question what if there was also an epsilon from q1 to q3 and an epsilon from q3 to q2 what would the starting state look like in the DFA?

  • @munteanionut3993
    @munteanionut3993 Před 2 lety

    Thanks a lot! : D

  • @wentaohe3076
    @wentaohe3076 Před rokem

    very clear

  • @thelockenbubi7117
    @thelockenbubi7117 Před rokem

    Thx dude!

  • @ahmetkarakartal9563
    @ahmetkarakartal9563 Před 2 lety

    thank you so much

  • @mohammedmansour3567
    @mohammedmansour3567 Před 2 lety

    What do you do if you have a lamda transition?

  • @dewman7477
    @dewman7477 Před 3 lety

    I don't get the echelon part of determining the set of states.

  • @Leaf682
    @Leaf682 Před 3 lety

    At 3:11 shouldnt it be just q1 instead of just q2, since getting a 'b' wont let us transition out of that state?

    • @EasyTheory
      @EasyTheory  Před 3 lety

      I'm not sure where you're getting q1. Note that the state we are testing "from" is {q0, q1} - note that q0 does not have a "b" transition, and q1 does have one to q2. So the resulting "state" is {q2}.

  • @KonstructChannel
    @KonstructChannel Před 2 lety +1

    But what if theres no epsilon enclosure in the NFA? How do I start? Do I just have to start with a if f.e q0 points with a to q1?

  • @wujekjerry1188
    @wujekjerry1188 Před 3 měsíci

    Can someone explain to me how {q1, q3} + a = {q1, q2} ?? Thats the only thing I cant understand. Is it because theres no defined states from q3 for the input 'a' this 'thread' kinda 'dies' and we can ignore it completely while q1 when given 'a' can result with both q1 and q2 and thats how we compe up with that?

    • @ChamaliVishmani1999
      @ChamaliVishmani1999 Před 2 měsíci

      from q1 through 'a' we can go to states {q1,q2}. from q2 we cant go to any state using 'a' transition. So next, when we consider the epsilon closures of q1 and q2, i.e. which states we can go to using epsilon transitions, it is themselves ; {q1,q2}. Hope that helps!

  • @munteanionut3993
    @munteanionut3993 Před 2 lety

    What if I don't have Epsilon on my NFA?

  • @TiaDzn
    @TiaDzn Před rokem

    3:54 "The set of states I could be in from q_2 reading an 'a' is q_0, q_1, q_2" Could you please explain me why "q_1" too? Starting from q_2, with an epsilon we can't go anywhere, with an a we can only go in q_0 and q_2 itself, and with a b only in q_3. Where am I wrong? Thanks in advance.

    • @zeking3844
      @zeking3844 Před rokem

      From q_2 on input 'a' you can go to q0 and to the epsilon closure of q0 which is q1

  • @hlo6217
    @hlo6217 Před 2 lety

    intro is iconic lol 🤣🤣

  • @john_is_never_home6871

    "Just use a computer to do this, don't do it by hand".
    Meanwhile I'm over here studying for my thermotical foundations exam where I know that this will show up.

  • @caominhnhat1455
    @caominhnhat1455 Před 4 lety +3

    *heart react

  • @Mike-kq5yc
    @Mike-kq5yc Před 3 lety

    Can you eventually tell me which book(s) your videos rely on? Because the professor in our Theoretical Computer Science lecture is not explaining everything thoroughly and deeply. Thanks in advance.

    • @EasyTheory
      @EasyTheory  Před 3 lety

      It's mainly the Sipser textbook, 3rd edition. All the notation I use is from there too.

  • @gurkengerd9981
    @gurkengerd9981 Před 3 lety

    How is this a DFA? {q1,q3} have 2 inputs leading to the same state {q1,q2}. This makes it non-deterministic.

    • @EasyTheory
      @EasyTheory  Před 3 lety +4

      Not quite. Non-determinism happens when you have 2 transitions *with the same symbol* going from the same state. In this case, it's 2 transitions with *different* symbols. Only one of the two can possibly be taken at a time.

  • @itsweird3373
    @itsweird3373 Před 4 měsíci

    abi çok tatlısın da anlatırken niye sinirleniyorsun anlamadım

  • @ion_propulsion7779
    @ion_propulsion7779 Před rokem

    Ahhhhh why are you making me do it by hand Sir! 😡

  • @sharpvik
    @sharpvik Před 3 lety +1

    Man, I'm afraid you have a video in your ads...

  • @Tf_vincent
    @Tf_vincent Před 3 lety

    Don't understand for shit, plez make second vid...