The above examples motivate the following definition:

# Definition: Grammar (Syntax)

Let $\Sigma$ be an alphabet. A grammar (or syntax ) is a tuple $G=(V,T,R,S)$ consisting of

• $V\subset\Sigma^*$ a finite set of variables,
• $T\subset\Sigma$ a finite set of terminal symbols (or terminals), i.e. some special characters from the alphabet $\Sigma$ such that $V\cap T=\emptyset$.
• A non-empty, finite set of rules $R$, i.e. pairs $(P,C)\in R$ of premises $P$ and conclusions $C$ such that $P\in (V\cup T)^*V (V\cup T)^*$ is a string containing at least one variable and $C\in(V\cup T)^*$ is a string.
• $S\in V$ as a starting symbol (a first to be replaced terminal symbol)

### Notes

• A syntax rule $R$ expresses how a string $P$ containing a variable can be transformed into another string $C$.
• Syntax rules can be optional, for instance, $S\to HN$ and $S\to H$ might be two coexisting rules of syntax, replacing the starting variable by the concatenation of $HN$ or only by $H$.
• The (formal) language which is generated by the syntax, consists of all strings that can be generated when applying the ruleset, starting from the starting symbol.
• $(V\cup T)^*$ denotes the Kleene star of the union of all variables and all terminals of the grammar. Correspondingly, an element of this union is any (even the empty string) concatenation of variables and terminal symbols.

Examples: 1

Branches: 1
Chapters: 2 3 4 5 6
Definitions: 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
Examples: 26 27
Explanations: 28
Parts: 29 30
Proofs: 31 32

Github: ### References

#### Bibliography

1. Knauer Ulrich: "Diskrete Strukturen - kurz gefasst", Spektrum Akademischer Verlag, 2001
{"ft_lang_label":"__label__en","ft_lang_prob":0.67086774,"math_prob":0.9929862,"size":1801,"snap":"2023-40-2023-50","text_gpt3_token_len":538,"char_repetition_ratio":0.104062326,"word_repetition_ratio":0.0,"special_character_ratio":0.2937257,"punctuation_ratio":0.12154696,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99910045,"pos_list":[0,1,2],"im_url_duplicate_count":[null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-12-05T06:15:27Z\",\"WARC-Record-ID\":\"<urn:uuid:ba81ffd9-605c-4aa8-ac69-83bfbf1b0f64>\",\"Content-Length\":\"16373\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:b57080bf-7d40-4fd9-ac58-63e329618065>\",\"WARC-Concurrent-To\":\"<urn:uuid:85deeb84-a0d3-446c-b89e-64699c4cfc4e>\",\"WARC-IP-Address\":\"185.199.111.153\",\"WARC-Target-URI\":\"https://bookofproofs.github.io/branches/logic/grammar-syntax.html\",\"WARC-Payload-Digest\":\"sha1:JKAKFOT3PAM6YYGPZVPG6XPIZYXBHIBB\",\"WARC-Block-Digest\":\"sha1:LDGLPQKDLBRLYVSNSTQZKIE6RTFQOF7X\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-50/CC-MAIN-2023-50_segments_1700679100545.7_warc_CC-MAIN-20231205041842-20231205071842-00013.warc.gz\"}"}