{"id":6541,"date":"2026-03-15T10:50:55","date_gmt":"2026-03-15T05:20:55","guid":{"rendered":"https:\/\/study.madeeasy.in\/?p=6541"},"modified":"2026-03-30T16:51:01","modified_gmt":"2026-03-30T11:21:01","slug":"context-free-grammar","status":"publish","type":"post","link":"https:\/\/www.madeeasy.in\/study\/cs-it\/context-free-grammar","title":{"rendered":"Context Free Grammar"},"content":{"rendered":"<h2 style=\"text-align: justify;\"><strong>Definition<\/strong><\/h2>\n<p style=\"text-align: justify;\">A context-free grammar G is a quadruple (V, T, P, S), where:<\/p>\n<ul>\n<li style=\"text-align: justify;\">V is the set of non-terminals. (Non-terminals used in the grammar and they do not appear in strings of the language).<\/li>\n<li style=\"text-align: justify;\">T is the set of terminals.<\/li>\n<li style=\"text-align: justify;\">P is the set of productions. All productions in P have the form A \u2192 x where A \u2208 V and x \u2208 (V \u222a T)*.<\/li>\n<li style=\"text-align: justify;\">S is the start symbol, S \u2208 V.<\/li>\n<li style=\"text-align: justify;\">Every regular grammar is context free, so a regular language is also a context free one.<\/li>\n<li style=\"text-align: justify;\">Family of regular language is a proper subset of the family of CFLs.<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-6542 size-full\" src=\"https:\/\/study.madeeasy.in\/wp-content\/uploads\/2026\/01\/context-free-grammar.jpg\" alt=\" context-free grammar\" width=\"257\" height=\"255\" srcset=\"https:\/\/www.madeeasy.in\/study\/wp-content\/uploads\/2026\/01\/context-free-grammar.jpg 257w, https:\/\/www.madeeasy.in\/study\/wp-content\/uploads\/2026\/01\/context-free-grammar-150x150.jpg 150w\" sizes=\"auto, (max-width: 257px) 100vw, 257px\" \/><\/p>\n<p><strong>Example:<\/strong><br \/>\nThe grammar G = ({s}, {a, b}, s, p) with productions.<\/p>\n<p style=\"text-align: center;\">S \u2192 aSa<br \/>\nS \u2192 bSb<br \/>\nS \u2192 \u03bb<\/p>\n<p>is context free A typical derivation in this grammar is<\/p>\n<p style=\"text-align: center;\">S \u2192 aSa \u2192 aaSaa \u2192 aabSbaa \u2192 aabbaa<br \/>\nthis, and similar derivations, make it clear that<br \/>\nL(G)={ww R : w \u2208 {a, b}*}<\/p>\n<p style=\"text-align: center;\"><a class=\"btn btn-danger\" role=\"button\" href=\"https:\/\/study.madeeasy.in\/cs-it\/regular-expressions\" target=\"_blank\" rel=\"noopener\">&lt;&lt; Previous<\/a> | <a class=\"btn btn-success\" role=\"button\" href=\"https:\/\/study.madeeasy.in\/cs-it\/leftmost-and-rightmost-derivations\" target=\"_blank\" rel=\"noopener\"> Next &gt;&gt;<\/a><br \/>\n<strong> Must Read: <\/strong> <a href=\"https:\/\/study.madeeasy.in\/cs-it\/what-is-theory-of-computation\" target=\"_blank\" rel=\"noopener\"><strong>What is Theory of Computation?<\/strong><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Definition A context-free grammar G is a quadruple (V, T, P, S), where: V is the set of non-terminals. (Non-terminals<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,1930],"tags":[1940,1941],"class_list":["post-6541","post","type-post","status-publish","format-standard","hentry","category-cs-it","category-computation","tag-context-free-grammar","tag-derivation"],"_links":{"self":[{"href":"https:\/\/www.madeeasy.in\/study\/wp-json\/wp\/v2\/posts\/6541","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.madeeasy.in\/study\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.madeeasy.in\/study\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.madeeasy.in\/study\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.madeeasy.in\/study\/wp-json\/wp\/v2\/comments?post=6541"}],"version-history":[{"count":0,"href":"https:\/\/www.madeeasy.in\/study\/wp-json\/wp\/v2\/posts\/6541\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.madeeasy.in\/study\/wp-json\/wp\/v2\/media?parent=6541"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.madeeasy.in\/study\/wp-json\/wp\/v2\/categories?post=6541"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.madeeasy.in\/study\/wp-json\/wp\/v2\/tags?post=6541"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}