Context-Free Grammars (CFG) and Context-Free Languages (CFL) - what are they?

Поділитися
Вставка
  • Опубліковано 16 жов 2024

КОМЕНТАРІ • 72

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

    Thanks to my supporters Yuri, vinetor, Ali (UA-cam) and Bruno, Timmy, Micah (Patreon) for making this video possible! If you want to contribute, links are in the video description.

  • @itsZybn
    @itsZybn 4 роки тому +105

    Hey man, just wanted to say I really appreciate you taking the time to make a video like this. Your work does not go unnoticed!

    • @EasyTheory
      @EasyTheory  4 роки тому +12

      Much thanks for watching

  • @unit220
    @unit220 2 роки тому +36

    It's actually maddening that I've spent hours with my professors trying to wrap my head around concepts like this and you destroy almost all my doubts in just 18 minutes haha, thank you so much for all of your vids!

  • @fishfishfishfishfishfish
    @fishfishfishfishfishfish 3 роки тому +26

    This video came just in time, I just finished my exam a few minutes ago. I don't think there's any way I would have passed without your videos!

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

      You're very welcome, and good luck!

  • @jackmccarthy7644
    @jackmccarthy7644 3 роки тому +14

    Exercise from video: Proving PAL isn't regular.
    We will prove this with the pumping lemma. First, assume PAL is regular, so it has a pumping constant p.
    Take the string w=(0^p)1(0^p). This is in PAL because it is a palindrome, and it has a length greater than p.
    Then, set w=xyz, where |y|>0 and |xy|0)
    z=(0^p-a-b)1(0^p)
    Then, by the pumping lemma, we know all x(y^i)z are in PAL. Take i=2:
    x(y^2)z = (0^a)(0^b)(0^b)(0^p-a-b)1(0^p) = (0^p+b)1(0^p)
    This can only be in PAL if it's a palindrome, which is only possible if the zero's on the left and right size of the 1 are equal. So we have:
    p+b=p --> b=0
    Which is a contradiction because we know the length of y is greater than 0.
    Therefore, PAL can not be regular.

  • @al8905
    @al8905 4 місяці тому +1

    speed running your videos for finals tomorrow, thanks for the knowledge

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

    Thanks for the video you are really saving lives here.
    My prof just gave us 2 powerpoint slides not even videos or lectures.
    I'd like to request videos solving problems from the book. The biggest challenge I'm finding is that lectures like yours can be very helpful but the problems are just way harder. Anything helps. Keep it up!

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

      I have some already made. Will make more. Here's the playlist of the ones I've already done: ua-cam.com/video/CvQDtQNqfAw/v-deo.html&ab_channel=EasyTheory

  • @fredrik1164
    @fredrik1164 3 роки тому +4

    Thank you so much for making detailed and informative videos like this, thanks to you I feel more confident for my exam tomorrow :)

  • @ketcup269
    @ketcup269 19 днів тому

    Great example my prof went over this one in class but just wasnt getting it. Glad u used sipsor as well !! i saw ur recent video about whats the point as well and loved that view as i was one who thought the more negative way of things. hope ur doing well !

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

    The best lesson's creator for this subject
    Please decrease the amount of adds this is so annoying!!!!!

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

    that's great, you're making Autumata much more interesting.

  • @mellowbun2022
    @mellowbun2022 4 роки тому +2

    Thank you for taking the time to make this man! This is much better explained than my teacher haha

    • @EasyTheory
      @EasyTheory  4 роки тому +1

      You're welcome! Make sure to send this to everyone you know ;)

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

    The way you teach is so good!!!!

  • @emmanuel-luka
    @emmanuel-luka 3 роки тому +2

    Thanks for the video man, it's really helpful

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

    Bro you just saved my exam thanks!

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

    CFG is basically the axiom of specification in set theory... well, not equivalently speaking, but the same concept applies. Every A and every conditional; exists B, which holds all membership A and A's conditions.

  • @SharminSultana-uq8go
    @SharminSultana-uq8go 5 місяців тому

    2024- Still best series so far!

  • @Gzzzzzz111
    @Gzzzzzz111 4 роки тому +2

    Thank you for the video! It really helps out since my prof Obrenic sucks at teaching. :)

  • @rachelsimaginarium
    @rachelsimaginarium 3 роки тому +4

    This was so helpful! Thank you!!

  • @bb-xj9ed
    @bb-xj9ed 3 роки тому +3

    thank you for not having a thick indian accent

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

    you're an actual hero.

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

    Amazing Explanation !
    Also can you tell me the name of the theme playing in your channel intro , it sounded really good !

  • @Peter-bg1ku
    @Peter-bg1ku 2 роки тому

    Amazing explanation. I bet you a five year old can easily understand CFG by watching this video :-) Thank you!

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

    After watching the video I came up with these doubts:
    Does the language of even-length palindromes form a context-free grammar?
    Does the language of words that have more a's than b's form a context-free grammar?
    Can every grammar be simplified to a regular grammar?

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

      1. In case of language of even length palindrome strings over any 2 terminals, yes, its grammar is indeed a CFG. You can create a PDA for this which in turn proves that its a CFG.
      2. It is also a CFL as you can create its PDA
      3. As per Chomsky Hierarchy we know that a regular grammar is also a recursively enumurable grammar but thats not vice versa. So, you cannot simplify any grammar into a regular grammar. The languages differ.

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

    Would this also work as a CFG for PAL?:
    S = 0A | 1B | 0 | 1 | E
    A = 0 | S0
    B = 1 | S1

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

    thanks for helping me understand this stuff, instant subscribe!

  • @bryanromero1
    @bryanromero1 3 роки тому +4

    Where were you when I took theory of computation :(

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

      In your context-free dreams

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

    Thanks for the video!

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

    You are amazing thank you so much!!!!!!! Very good explanation :)))

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

    Can you tell me what’s the name this application you use?

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

    Great video! Do you maybe have video on generation trees and Lukasiewicz notation? It's in the CFG chapter of Cohen's book

  • @Marcalitus
    @Marcalitus 4 роки тому +13

    Thank you so much, I know you might not think anyone is watching but I am thankful I clicked and it wasn't another Indian because they've been haunting my dreams.

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

      Lmao thanks for your viewership! I do read all comments :)

    • @Marcalitus
      @Marcalitus 4 роки тому +4

      @@EasyTheory shared your videos and playlist with all my class mates. Thank you so much for your time.

    • @EasyTheory
      @EasyTheory  4 роки тому +4

      @@Marcalitus Much appreciated!

    • @Panthera-Uncia
      @Panthera-Uncia 7 місяців тому

      Agreed. Much love to my fellow Americans.

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

    Would this work for palindromes?
    S -> 0 | 1 | E | 0B0 | 1B1, B ->0B | 1B | E

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

    holy crap THANK YOU

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

    thank you so much for this

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

    Nice explanation

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

    by any chance, a CFG cannot generate a regular language?? and what is the best way to prove if a CFG can or cannot generate regular language?

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

      Every regular language is context-free, so a CFG can always be made for a regular language. Note that every regular language has a regular grammar, which already is a CFG.

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

      @@EasyTheory Thank you for your help. Btw is S -> Aaa or S -> aa are also regular grammar?

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

      @@MsCrycry not strictly speaking. The only allowed rule types are of the form A -> x, where A is a single variable, and x is empty string, a single terminal, a single variable, OR a single terminal then a single variable. So those rules are not in the allowed rule types.
      However, they describe a regular language, so there exists a regular grammar for it (just that it's not involving the rules you gave).

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

    Very good video and damn, you're attractive, and so is your voice

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

    thaaanks a lot

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

    Professor, at 4:20 you inserted a comma into the string!

  • @Christine-ne3dw
    @Christine-ne3dw 3 роки тому

    Thank you, sir :)

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

    Thanks!

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

    Tnx man😅

  • @5beastman5
    @5beastman5 2 роки тому

    goated

  • @climbersisyphus
    @climbersisyphus 6 місяців тому +1

    5 minutes in and i have no idea what you're saying.

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

    ur so cool....

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

    handsome and smart

  • @parkergent5294
    @parkergent5294 19 днів тому

    I have never hated a class or subject more than this

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

    intro music is out of time

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

    This is the worst class. You dont realize how lucky you are that you have hundreds of years of pedagogy behind math until you take theoretical computer science classes and see how makeshift the pedagogy is.