UniFormal / MMT

The MMT Language and System
https://uniformal.github.io/
Other
68 stars 23 forks source link

Document notations more thoroughly #516

Open ComFreek opened 4 years ago

ComFreek commented 4 years ago

Forms of Notations and How to Specify Notations

MMT distinguishes multiple forms of notations; every constant can have none, some, or all of them: parsing notation, presentation notation, (a third I forgot)

For a constant, a parsing notation is specified using a constant component # <notation syntax here> that starts with a hash symbol. A non-exhaustive list of syntax examples is:

For a constant, a presentation notation is specified using two hash symbols ## <presentation notation syntax here>. Unless otherwise noted, the presentation notation syntax follows the same syntax as normal notation syntax.

Syntax of Notations

Special characters within notation components: %, digits 0-9, V, (these four categories as reverse-engineered from here), jOD, jDD, jMD. The first two can be escaped via %D and %R, see second bullet point below.

OMA vs ApplySpine

MMT uses OMDoc as the grammar for terms, mostly. In OMDoc the OMA production serves to encode function applications. E.g. in pure OMDoc, you could encode "the function f applied to variable x (in scope)" as OMA(OMS(...path to f), OMV("x")) (if "x" is a variable in scope).

Within a theory which has (transitively) LF as a meta theory, almost all function applications such as f x get turned into the OMDoc term OMA(?LFApply, List(f, x)), where LFApply is an untyped constant written down in MMT/urtheories.

(beware: if LF is only "included", i.e. via regular inclue, notations aren't touched.)

theory T theory S definiens component of d
{c # not, x, y} include ?T, d = not x y OMA(?c, List(?x, ?y))
{c # not, x, y} include ?T, include ?LF, d = not x y OMA(?LFApply, List(?c, ?x, ?y))
{c # not 1 2, x, y} include ?T, d = not x y OMA(?c, List(?x, ?y))
{c # not 1, x, y} include ?T, include ?LF, d = not x y OMA(?LFApply, List(OMA(?c, ?x), ?y))
{c # not 1 2, x, y} include ?T, include ?LF, d = not x y OMA(?c, List(?x, ?y))

in non-LF contexts it doesn't make a difference whether argument marked had been provided or no

rappatoni commented 3 years ago

Thanks for this write-up. I updated the documentation slightly to account for it. For now I have marked flexary notations as experimental.

rappatoni commented 3 years ago

Still need to document the L, %L, and V, %i, %n cases.

ComFreek commented 3 years ago

I think an overview table with columns "modifier", "short desc." and "example" (e.g. with entry %R | right associativity | 1 %R=> 2) would be nice in the documentation. Furthermore, we could maintain a longer prose text with more examples (as is the case now).

(Not saying you in particular should do this; just something next time someone picks up documentation.)