docs: Update to reflect pending changes in the Spoofax Tutorial/Reference

This commit is contained in:
Glen Whitney 2021-02-03 16:24:47 -08:00
parent ba130ecb0f
commit ae0a798c7b
8 changed files with 107 additions and 385 deletions

View file

@ -267,40 +267,6 @@ test chap9_cnf7_ex [[
Or(Not(Atom("r")), Atom("q"))),
Atom("p"))
/** md
The key point to know about
[Chapter 9](http://www.metaborg.org/en/latest/source/langdev/meta/lang/stratego/strategoxt/09-traversal-strategies.html),
however, is that there is a mistake that affects examples `prop-dnf8` through
`prop-dnf10`. The difficulty is in this definition:
```Stratego
strategies
propbu(s) = proptr(propbu(s)); s
```
Recall that `proptr` is defined as follows: (Note that our implementation calls
it `proptr7` to distinguish it from different definitions for `proptr` in other
examples.)
```Stratego
{! ../trans/prop-dnf7.str extract:
start: '(rules\n*)'
stop: strategies
!}
```
So `propbu` must be defined as:
```Stratego
{! ../trans/prop-dnf8.str extract:
start: strategies
stop: '(.*propbu8.*)'
!}
```
The point is that `proptr` cannot apply to `Atom`s and logical constants, and so
fails when it reaches such nodes in the AST. Without the `try` in the definition
of the `propbu` traversal, any such failure propagates to a failure of the entire
strategy.
**/
test chap9_dnf8_ex [[
(r -> p & q) & p
]] run dnf8 to Or(And(Not(Atom("r")),Atom("p")),And(And(Atom("p"),Atom("q")),Atom("p")))
@ -311,10 +277,6 @@ test chap9_cnf8_ex [[
Or(Not(Atom("r")), Atom("q"))),
Atom("p"))
/** md
Example `prop-dnf9` simply re-uses `propbu8`.
**/
test chap9_dnf9_ex [[
(r -> p & q) & p
]] run dnf9 to Or(And(Not(Atom("r")),Atom("p")),And(And(Atom("p"),Atom("q")),Atom("p")))
@ -325,14 +287,6 @@ test chap9_cnf9_ex [[
Or(Not(Atom("r")), Atom("q"))),
Atom("p"))
/** md
And a similar fix is made to `prop-dnf10`:
```Stratego
{! ../trans/prop-dnf10.str !}
```
**/
test sec9_1_dnf10_ex [[
(r -> p & q) & p
]] run dnf10 to Or(And(Not(Atom("r")),Atom("p")),And(And(Atom("p"),Atom("q")),Atom("p")))
@ -343,22 +297,6 @@ test sec9_1_cnf10_ex [[
Or(Not(Atom("r")), Atom("q"))),
Atom("p"))
/** md
There is another issue in the "Format Checking" example in section 9.1. It lies
with the strategy used to determine if an expression is an atom or the negation
of an atom. The expression shown is `Not(Atom(x)) <+ Atom(x)`. This appears to
be a left choice of two congruences. But a congruence expects a strategy as an
argument, whereas here `x` is simply a free variable. There are a couple of
fixes to write an expression that checks whether a term is just an `Atom()` call
or the negation of one. The first possibility is to use match expressions, e.g.
`?Not(Atom(x)) <+ ?Atom(x)`. However, as that can run into issues with the scoping
of the variable `x`, we opted for sticking with the congruences, just using a
strategy that always succeeds in the inner position, namely `id`:
```Stratego
{! ../trans/sec9_1.str terminate: exercise !}
```
**/
test sec9_1_disj-nf_fails [[
(r -> p & q) & p
]] run disj-nf fails
@ -386,7 +324,7 @@ test sec9_1_cnf11_ex [[
Atom("p"))
/** md
Also note that the repository does not include `prop-dnf12` because at this
Note that this repository does not include `prop-dnf12` because at this
point the strategies there have become identical to the ones
in {! ../docrefs/sec6.2.md !} used to introduce the idea of splitting
transformations into local rewrite rules applied via a traversal strategy. So
@ -454,8 +392,7 @@ test sec9_2_impl-nf_once [[
]] run impl-nf2 to Impl(Impl(Atom("p"),Impl(Atom("q"),False())),False())
/** md
I couldn't think of a natural application of paramorphism in the context of
the Spoofax Propositional Language, so there is no solution provided for the
On the other hand there is no solution provided for the
exercise just before
[Section 9.2.1](http://www.metaborg.org/en/latest/source/langdev/meta/lang/stratego/strategoxt/09-traversal-strategies.html#cascading-transformations).