Today I Learned

Some of the things I've learned every day since Oct 10, 2016

15: Context-Free Grammars

context-free grammar is a formal grammar in which the rewrite rules (or ‘productions’) of the grammar are all from single variables. That is, as implied in the name, the rewrite rules of a given variable in a context-free grammar are dependent only on that variable and not on any other ‘context’.

Example:

This is a valid subset of rewrite rules in a context-free grammar

X \rightarrow a

Y \rightarrow ab

while this is not

X \rightarrow a

Y \rightarrow ab

XY \rightarrow c

The violation of freedom-from-context in the latter example is due to the last rule, where the thing being rewritten is not a single variable.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: