Formal Definition of Systematic Grammar
twitter extempore! on formally define the concept of “systematic grammar”
- over the past 2 decades, i had a idea about a comp lang with systematic/simple grammar.
- Now i know how to define it formally.
- Wolfram Language is one specific example am trying to describe, a idea of “systematic” grammar.
- on the surface, Wolfram language code is not at all “regular” in the normal English sense of “regular”
- if you look at it, it is extremely complex, perhaps more so than perl.
- however, it's systematic. Very regular. But, how on earth can you define this “regularity” or “systematic” or “structured” formally?
- A language whose context free grammar spec in BNF is itself a linear/regular language.
- if you have studied parsers, then you know what i mean.
- else, basically it means, a language's grammar of grammar is regular!
- now, let's dive in a bit about concept of “simple” grammar and “systematic” grammar.
- simple grammar, is for example, idealized LISP, XML, APL, TCL. Look at their code. Syntax is simple.
- first, a aside, why i say “idealized” lisp syntax? because lisp syntax, is not really regular in english sense. Nor is XML.
- lisp, everything is of the form
(a b c …), but actually, NOT!
- eg in lisp, you have
(a . b),
`(a ,@ b ,c)
;comment. These are all irregular!
- in XML, you'd think everything is
<f x=b …>…</f>, but there's also
<?xml version="1.0" encoding="UTF-8"?>, broke regularity
- XML also has
<!-- comment -->, and
<![CDATA[…]]>, broke regularity.
- so, idealized LISP is “regular”. For example, in idealize LISP, all's
- idealized XML is “regular”. For example, in idealize XML, all's
- now another aside. In computer science, the term “regular grammar” has very specific techincal meaning, not “regular” of English sense.
- In computer science, what “regular grammar” mean you can lookup. Basically it means what regex can match. Or, strings sans nesting.
- as soon as your lang has paren/brackets (thus nesting), its grammar is not regular in comp sci sense.
- the comp sci jargon of “regular grammar” & “regular language” is annoying, because it's misnomer/misleading.
- anyway, what we are talking here is “regular” in English sense. Similar to “uniform”, as in no exceptions. Also, close to “simple”.
- now, let's talk about the concept of “simple/regular” grammar. For example, idealized lisp syntax, or XML, or APL
- simple grammar is great, but they may not be flexible. eg lisp, you can't do 3+4/5. When it's long, put it in lisp is pain to read.
- so, how to keep syntax “regular/simple”, yet flexible? comes the idea of “systematic” grammar.
- let's illustrate a example of systematic grammar, with english!
- in english, let's start with subject verb object, for example, i love u, i drink coffee, i go home.
- now, create a set of words, and these can go before noun. We call these words adjectives. Same for adverb for verb
- now, for every noun, we can add “s” to the end to mean “more of it”, and NO EXCEPTIONS.
- eg, we have ass=1 ass, asss=more than 1 ass. mouse/mouses, man/mans, wife/wifes
- same way we SYSTEMATICALLY add inflections, and other, but NO Exceptions. You see, just few simple rules, but sentence can become flexible.
- this is what i meant “systematic” grammar. Given such a lang, the code may not look simple, but the grammar is simple.
- and the way to formally define this “systematic grammar”, is a grammar whose grammar is regular in comp sci sense.
- lisp, xml, APL, TCL, are somewhat simple grammar, but as far as i know only Wolfram Language is systematic grammar.
- while perl,ruby,C etc, their grammar are not simple, nor regular in any sense. They are, ad hoc grammar. Some come close to simple, ruby.
- don't confuse “simple” with “familiarity”. familiarity comes with exposure. Chinese 中文 is familiar/easy to me, but is not simple.
- C syntax and derivatives, for example: java C++ js, are familiar, easy, because C made it popular, wide exposure.