The classic example of a context-free grammar is $a^nb^n$. That is, $n$ occurrences of $a$ followed by an equal number of occurrences of $b$.Do such forms occur in the real world? Can you provide an example of a real-world case where there must be $n$ occurrences of something followed an equal number of occurrences of something else?Let me give an example: if I run an on-line store, then for each purchase made to my store, there must be a corresponding delivery of the purchased item. That might be modeled as $n$ purchases followed by $n$ deliveries:purchase purchase purchase delivery delivery deliveryHowever, that is not a good data model since each delivery should legitimately be paired to a purchase:purchase delivery purchase delivery purchase deliverySo I am left wondering if there are any real-world examples where data would be (legitimately) modeled as a sequence of $n$ items of one type followed by $n$ items of another type. Can you provide a real-world example please?Hendrik Jan provided this good example (see it in the comments below): This weekend I visited my mother. Three flights up, and three flights down when I left. Neat example! Can you think of others?A colleague just informed me of another example. In the KML specification it says that a <Track> element must contain N <when> elements followed by N <gx:Coord> elements:https://developers.google.com/kml/documentation/kmlreference#gxtrackAnother excellent example. What are other examples?Another colleague sent me an article about columnar databases. It is often more efficient to store data in columns rather than rows. For example, we may have a column of person's ages followed by a column of person's heights. Or, a list of N integers (ages) followed by a list of N decimals (heights). This enables efficient calculation of sums or averages. Here's the article:http://www.postgresql.org/message-id/52C59858.9090500@garret.ruMore examples please! I would like for us to create a nice collection of compelling examples.
Is $a^n b^n$ an artificial language or does it occur in the real world?
formal languages;context free;modelling