SASyLF may make writing proofs a lot easier, but that still doesn't
mean that it's exactly *easy* to use SASyLF correctly. Even basic
support in a sufficiently powerful text editor can be extremely
helpful. To that end, I have created a SASyLF mode for jEdit (http://
jedit.org). To date, Dr. Boyland has been storing this on the AFS
volume for his type theory course, but it occurred to me that it just
might benefit other people who are using the language. The current
version of the mode has been uploaded to the group "Files" section.
Features
=======
This mode supports both auto-indentation (tabs not spaces) as well as
contextual syntax highlighting. Note that this is *not* semantic
highlighting alla some mainstream IDEs; jEdit has no meaningful
understanding of SASyLF or the source file you are working on.
Features include:
* Top-level keywords like `theorem` and `lemma` are highlighted
differently from secondary ones such as `forall` and `rule`
* Statement labels are highlighted specially, but this highlighting is
*not* applied to type rules (conventionally declared using a colon)
given in the rules. Note that this only works so long as all rules
come previous to any theorems or lemmas
* Judgment, theorem and lemma names are given distinct highlighting
* Justifications are highlighted according to the syntactic element to
which they correspond. For example:
s1: ... by d1
s2: ... by rule absolutely-true on d1, s1
s3: ... by induction hypothesis on s2
In statement s1, "by" is highlighted as an operator, while "d1" is
recognized and properly highlighted as a statement label. Likewise,
in s2, "absolutely-true" is known to be a rule, thus is given the
appropriate highlighting; "on" is an operator and both "d1" and "s1"
are highlighted as statement labels.
* Multi-token keywords are handled appropriately (and in some cases,
contextually). For example, "induction" is a keyword, but
"hypothesis" is not. Only when they appear together in a
justification are they both highlighted.
* Rule separators are highlighted (seems like a minor thing, but I'm
proud of it) :-)
* Token "x" (and likewise, " x' ", "x1", etc) is recognized as magic
and highlighted specially in all contexts
* Special justification "unproved" gets its own highlighting in an
attempt to make it more noticeable
Known Quirks
==========
* Justification must remain on the same line as the statement,
otherwise the auto-indentation cannot handle it. Thus:
s1: ...
by theorem my-test on d2
SASyLF is fine with this, but jEdit's auto-indenter is not powerful
enough to properly add extra indentation to a dangling "by". Thus,
these lines will actually be auto-indented as follows:
s1: ....
by theorem my-test on d2
Not a huge deal, but worth remembering. Nothing really *bad*
happens if you manually override the auto-indenter, it's just extra
work.
* Rules must come before any theorems
* Since there is no official spec for SASyLF (or even a language
README), I had to guess on syntact elements. Thus, it's possible that
I missed some keywords (I added "weakening" for the first time a week
ago).
* No support (yet) for 0.20's mutual induction syntax.
* If you *ever* dare to use ASCII character 222, all hell will break
loose and I wouldn't be surprised if the editor itself crashed.
Fortunately, I don't think that SASyLF's lexer would be too happy
either...
This is an incredibly contextual highlighting schema. Due to the way
I had to write this in jEdit's mode definition syntax, you should
expect a fair number of strange problems whenever you stray off of the
syntactic beaten path. I think I've ironed out most of the issues (at
least, it seems to highlight all of the samples correctly), but don't
be surprised if things don't color nicely when you arrange things in
an unexpected way.
Please let me know if you run across any issues. So long as I have a
sample file to reproduce, I should be able to fix (or at least hack
around) any serious inconsistencies which may (read: almost certainly)
still exist.