Last active
October 26, 2023 23:53
-
-
Save grondilu/544b66d2b93a9e5b07d030c7b7d5bffe to your computer and use it in GitHub Desktop.
Metamath raku grammar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Metamath commentless grammar | |
# remove comments beforehand with | |
# .subst: / '$(' ~ '$)' .*? /, '', :g | |
unit grammar Metamath; | |
rule TOP { ^ <database> $ } | |
rule database { <outermost-scope-stmt>* } | |
rule outermost-scope-stmt { | |
| <include-stmt> | |
| <constant-stmt> | |
| <stmt> | |
} | |
rule include-stmt { '$[' ~ '$]' <filename> } | |
rule constant-stmt { '$c' ~ '$.' <constant>+ } | |
rule stmt { | |
<block> | | |
<variable-stmt> | <disjoint-stmt> | <hypothesis-stmt> | <assert-stmt> | |
} | |
rule block { '${' ~ '$}' <stmt>* } | |
rule variable-stmt { '$v' ~ '$.' <variable>* } | |
rule disjoint-stmt { '$d' ~ '$.' <variable> ** 2..* } | |
rule hypothesis-stmt { <floating-stmt> | <essential-stmt> } | |
rule floating-stmt { <LABEL> '$f' ~ '$.' [<typecode> <variable>] } | |
rule essential-stmt { <LABEL> '$e' ~ '$.' [<typecode> <MATH-SYMBOL> *] } | |
rule assert-stmt { <axiom-stmt> | <provable-stmt> } | |
rule axiom-stmt { <LABEL> '$a' ~ '$.' [ <typecode> <MATH-SYMBOL> * ] } | |
rule provable-stmt { | |
<LABEL> '$p' <typecode> <MATH-SYMBOL> * '$=' ~ '$.' <proof> | |
} | |
rule proof { <uncompressed-proof> | <compressed-proof> } | |
rule uncompressed-proof { [ <LABEL> | '?' ] + } | |
rule compressed-proof { [ '(' ~ ')' <LABEL> * ] <COMPRESSED-PROOF-BLOCK> + } | |
rule typecode { <constant> } | |
rule filename { <MATH-SYMBOL> } | |
rule constant { <MATH-SYMBOL> } | |
rule variable { <MATH-SYMBOL> } | |
token MATH-SYMBOL { <+[\H]-[$]>+ } | |
token LABEL { <+alpha+digit+[.-]>+ } | |
token COMPRESSED-PROOF-BLOCK { <[A..Z?]>+ } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment